一个方法返回两个返回值 就是一个方法中,如何能够返回两个值 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ref out 参数或者返回数组,列表,之类的组合数据 返回一个对象,包含两个字段或者使用out,ref 参数 例:int a=0;int b=0;aa();void aa(ref a,ref b){ a=10; b=11;} 1.out和return共用1.全部用out2.返回数组 类 tuple<item1,item2> 可以尝试把返回值封装进数组、集合等,或者ref out 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";} 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参与具体计算变化 //...} C#多条件查询怎么实现? 求采集百度结果页面网址正则表达式 C# 结构 怎樣把這段代碼改為VB.NET C#中如何使用参数调用Oralce存储过程,急等! VS2005能够对单文件进行运行,调试吗? 弱弱的问题,怎么对label进行绑定 【C# Http Post DirectX】用Http协议从摄像头端获取声音的实现过程 页面显示的位置怎么确定。那位给个方法 请问各位大哥大姐,有什么经典的C#视频和书吗?可以介绍下吗? 如何根据数据库某一字段的值,将gridview行变灰色,不可以编辑。 寻高手,关于webBroser,与论坛自动发帖有关
或者返回数组,列表,之类的组合数据
或者使用out,ref 参数
int a=0;
int b=0;
aa();
void aa(ref a,ref b)
{
a=10;
b=11;
}
1.全部用out
2.返回数组
tuple<item1,item2>
{
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";
}
Tuple<int,string> M(){}另外如楼上各位 也可以用ref或outvoid Test(out double d1,out double d2){
d1=d2=0.0d;
//...d1,2参与具体计算变化
//...
}