vendredi 8 juin 2018

How to convert a variable type to another variable type

I have an object array which all has been filled with specific command arguments (of type string):

object[] args = {"@all", "1", "true"};

And I have this method:

public void Method(string client, int num, bool type)<br/>

I want to pass the arguments specified in the object array to the method. How can I convert each object array element to the specific types expected by the method?

Note The method parameter types ARE NOT FIXED, so I need to convert the items in the object array to different types that are unknown at compile time.





Aucun commentaire:

Enregistrer un commentaire