Is C# capable of handling method versions?
For example, if I have two methods with same name and parameters in Ruby, the most recent version gets executed.
How C# handles this? Will it raise an error or execute the recent version?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You cannot have two methods with the same name and parameter list in the same class in C#. You need to differentiate the methods somehow, either use different names or differing parameter types and/or different number of parameters. You will simply get a compilation error.
While there is no notion of “most recent version” of a method in C#, it sounds like you are trying to accomplish a form of method overriding (I’m not familiar with ruby so I do not know what most recent version means), you may be able to achieve something similar by sub-classing and method overriding.