C# 类参数列表不确定
电脑版发表于:2021/3/10 17:30
不确定参数数目使用 params ,再用数组接收
//定义方法的时候参数类型是确定的
public static string Strformat(this string str, string a, int b, string c)
{
return String.Format(str, a, b, c);
}
//改过之后
public static string Strformat<T>(this string str, params object[] items)
{
return String.Format(str, items);
}