Use C# for Addin in Excel
-
i already did in VB few month ago, and i want to do the same in C#. the function insert in DB the info i get in excel and works well. ' example in VB public function myFunction(byval LastName as string, byval FirstName as string, optional Email as string="NA", optional PhoneNbr as long=0) end function // now how can i do the same in C#? i can do with polymorphiste but if some function have 20 argument, i need 400 different functions to do the equivalent of vb? the missing value work, but i need to put all the argument in object type. Fardoche
-
i already did in VB few month ago, and i want to do the same in C#. the function insert in DB the info i get in excel and works well. ' example in VB public function myFunction(byval LastName as string, byval FirstName as string, optional Email as string="NA", optional PhoneNbr as long=0) end function // now how can i do the same in C#? i can do with polymorphiste but if some function have 20 argument, i need 400 different functions to do the equivalent of vb? the missing value work, but i need to put all the argument in object type. Fardoche
If all ur optional parameters are the same type, u can use the 'params' keyword. U could use it even if they weren't the same type, but u would need to use an object array which u dont want. Otherwise, the only solution is to overload ur 400 different functions, C# does not support optional parameters. params[^]