Now why should we use __arglist.
In case of each of these methods, the problems are :
1. If we use Method Overloading, we might have to add new methods whenever a new set of argument list is thought to be sent.
2. If we use param array we need to have same type of arguments or need to have param array of objects.
__arglist reveals each of those. It can send any no of argument to a function. It might be of any type and we can parse each argument easily using simple steps.
Lets have a look at the Code :
public int paramLength(__arglist)
{
ArgIterator iterator = new ArgIterator(__arglist);
return iterator.GetRemainingCount();
}
Now if I call the function using this statement
int x = this.paramLength(__arglist(49,34,54,6,"asdfg")); // returns 5
Read more: Daily .Net Tips