polymorphism without classes in C# -


i new object-oriented programming. problem when define method in class, can use method in way:

myobj.mymethod(params); 

but don't want method member of class, still polymorphic function. mean, want "free" function different things based on parameters. example:

mymethod(myobjoftype1, intvar); // works ints mymethod(myobjoftype2, stringvar); // different function works strings 

is possible in c#?

to make 'independent method' not possible in c# since there class or member of class.

to problem recommend using static class have static methods.

usage:

classname.methodname(); 

all methods different parameters should implemented inside class (method overloading).

but if doesn't suit you, should have @ generic methods (but in case need create @ least 1 class).


Comments

Popular posts from this blog

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

SQL Server - MyCTE query based on 24 hour period (next day) -

php - Using str_replace to translate a MySQL Table in html -