110,545
社区成员
发帖
与我相关
我的任务
分享
test(params object[] args){
// do something
}
string str1="";
string str2="";
test(str1,str2);
string str1="";
string str2="";
test(ref str1,out str2);
static void test(params object[] args)
{
args[0] = "12";
args[1] = "34";
}
static void Main(string[] args)
{
string str1 = "1";
string str2 = null;
object[] p = new object[] { str1, str2 };
test(p);
str1 = (string)p[0];
str2 = (string)p[1];
Console.WriteLine(str1); //“12”
Console.WriteLine(str2); //“34”
}
static void Main(string[] args)
{
object z = 1;
object[] p = new object[] { z };
typeof(Program).GetMethod("x").Invoke(null, p);
Console.WriteLine(z);
Console.WriteLine(p[0]);
}
public static void x(ref int z)
{
z = 999;
}
test(ref object[] args){
// do something
}
string str1="";
string str2="";
object[] obj = { str1, str2 };
test(ref obj);
str1 = obj[0].ToString();
str2 = obj[1].ToString();
[DataContract]
[Serializable]
public class result
{
public string str1;
public string str2;
...
}
result test(params object[] args);