1.params
个人理解就是可以动态的储存参数
例如代码:
public void HolloWorld (int id ,params string[] strParameter)
{
int ID = id;//这个可以单独使用
string a = strParameter[0];//输出 a
int b = Convert.ToInt32(strParameter[1])// 输出 2
}
//调用时
HolloWorld (3,"a","2",//N个参数);
2.ref
int i=0;
//方法
public void HolloWorld (ref int i)
{
i=2
}
//输出 i就等于2
3.out
int newTypeIdStr= 5;
public void HolloWorld (int newTypeIdStr)
{
int newTypeId = 0;
if(int.TryParse(newTypeIdStr, out newTypeId))
{
//如果是整型那这个newTypeId 就等于5
//输出newTypeId =5;
}else
{
//输出newTypeId =0;
}
}
//输出 i就等于2