C# 反向限制法

C# 反向限制法,c#,reverse,C#,Reverse,我正在运行下面的代码,没有任何调试问题,但我的结果是关闭的 这是我用来反转字符串的代码 { namespace Code2040 { public class ReverseString { public ReverseString () { Task.Run (async () => //helper function is the post function for the webrequest

我正在运行下面的代码,没有任何调试问题,但我的结果是关闭的

这是我用来反转字符串的代码

{ namespace Code2040
  {
   public class ReverseString
     {
    public ReverseString ()
      {
        Task.Run (async () =>

            //helper function is the post function for the webrequest
            var helper = new Helper ();
            Session.Instance.SetToken (JsonConvert.DeserializeObject<Response> (
                await helper.Post ("http://challenge.code2040.org/api/getstring", 
                    JsonConvert.SerializeObject (new { token = "Y6C15DVN99" 
                         }))).Result);
            Console.ReadKey (true);
            //Reads out the line to verify if the token was printed out 
            Console.WriteLine (alorgorithmForReversingString.reverser (Session.Instance.Token));
            //Console.WrtieLine (alorgorithmForReversingString.reverser (Session.Instance.Token));
            Console.ReadLine ();
            Console.WriteLine ("hello");
        });
    }
}

//Algorithim for reversing the string
static class alorgorithmForReversingString
{
    public static string reverser (string tokenResult)
    {
        Console.WriteLine ("Debug");
        char[] arr = tokenResult.ToCharArray ();
        Array.Reverse (arr);
        return new string (arr);

    }

  }
}


为了总结这段代码,我从一篇web文章中得到一个令牌值,我将其转换为一个字符串值,该字符串值被假定为反转字符串。但是,当我编译代码时,它甚至不会返回调试控制台write line变量。任何人都可以帮忙。

我的问题的解决方案是在TaskAsync方法中有Console.WriteLine。我相信TaskAsync方法只是运行webpost并返回结果

    public class ReverseString
{
    public ReverseString ()
    {

        Task.Run (async () => {

            //helper function is the post function for the webrequest
            var helper = new Helper ();
            Session.Instance.SetToken (JsonConvert.DeserializeObject<Response> (
                await helper.Post ("http://challenge.code2040.org/api/getstring", 
                    JsonConvert.SerializeObject (new { token = "Y6C15DVN99" 
                         }))).Result);
        });
        Console.WriteLine (alorgorithmForReversingString.reverser (Session.Instance.Token));
    }
}
}

可能相关: