Its strange but true that i got a requirement for the first time today where i wanted to pass variable number of parameters to a method i was writing in C#. Now i always knew that its possible however as soon as the requirement struck i just didn't have a clue about how to achieve this.
And so i hit the msdn and boy its so simple.
You just need to use params keyword to achieve this
So a method which needs multiple parameters of different type can be written as
public static void MethodName(params object[] parameters)
And it just works :)
Happy coding....
~Abhishek
No comments:
Post a Comment