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
Post a Comment