delegate void CallBack(ref int result);
    class Program
    {
        public
        static void Main(string[] args)
        {

            int restut = -1;
            CallBack cb = new CallBack(Call);
            cb.BeginInvoke(ref restut, null, null);//异步
            while (restut != 0)
            {
              Thread.Sleep(200);
            }
            Console.Read();
        }
        public static  void Call(ref int res)
        {
            Thread.Sleep(500);
            res = 0;//修改成0,但是主函数Main中的result还是-1,这是为什么呢,不是使用了ref吗
            //有大侠能在这里详细解释下吗,最后从堆栈的角度来分析
                   
            Console.WriteLine(res);
         
        }
    }
    

相关文章:

  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2022-02-22
  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2021-12-21
  • 2021-05-25
  • 2021-06-18
  • 2022-12-23
相关资源
相似解决方案