returns the class name of this class
this.GetType().ToString();
returns the class name and the namespace (full name)
I have about 10 classes and they share same functionality. But, they have different attributes. I am using interesting design for them. There is a parent class and then it performs the shared functionality and calls the method that subclass implement. I used this method in objective c and then in C#:
class Parent
{
DoSharedWork()
{
....
GetClassSpecificData ();
...
}
virtual Parent GetClassSpecificData()
{}
}
class Child
{
override Parent GetClassSpecificData ()
{
..do specific work
return this;
}
}
class Main
{
Child child;
child.DoSharedWork();
}
No comments:
Post a Comment