就是一个方法中,如何能够返回两个值

解决方案 »

  1.   

    ref out 参数
    或者返回数组,列表,之类的组合数据
      

  2.   

    返回一个对象,包含两个字段
    或者使用out,ref 参数
      

  3.   

    例:
    int a=0;
    int b=0;
    aa();
    void aa(ref a,ref b)
    {
       a=10;
       b=11;
    }
      

  4.   

    1.out和return共用
    1.全部用out
    2.返回数组
      

  5.   

    类 
    tuple<item1,item2>
      

  6.   

    可以尝试把返回值封装进数组、集合等,或者ref out 
      

  7.   

    private void static Main()
    {
        int num = 0;
        string str = null;
        Method(out num,out str);
        Console.WriteLine("The num is "+num.ToString());
        Console.WriteLine("The String is "+str);
        Console.ReadKey();
    }private void Method(out int num, out string str)
    {
        num = 123;
        str = "abc";
    }
      

  8.   

    4.0除了用out ref以外还可以用TupleTuple<customtype1,customtype2> M(){}example:
    Tuple<int,string> M(){}另外如楼上各位 也可以用ref或outvoid Test(out double d1,out double d2){
      d1=d2=0.0d;
      //...d1,2参与具体计算变化
      //...
    }