Use*_*ser -4 c# asp.net c#-4.0
class abc
{
public object test(params object[] par)
{
//I need Count of the parameter here which means to check par contains 1 or 1,2
}
}
I access the class like,
abc obj =new abc();
obj.test(1);
(or)
obj.test(1,2);
Run Code Online (Sandbox Code Playgroud)
我的问题是,有可能发送1或1,2.我需要在测试类的Object中有多少个参数的计数?怎么做?
使用Array.Length财产.
public object test(params object[] par)
{
var count = par == null ? 0 : par.Length;
}
Run Code Online (Sandbox Code Playgroud)