Calling derived class method

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I defined a property in a base class that will under certain condition return
its own value, but sometimes needs to pass the implementation to the derived
class. Now the proble is that in the method I need a name of the derived
class to perform some database query. It looks like this:

public abstract class MyAbstractClass
{
protected MyAbstractClass()
{
}

// This implementation will be forced with a derived class
public override string FindInDerivedClass
{
get;
}

public string FindSomething()
{

string found = CalculateSomething(<<<NameOfTheDerivedClass>>>);

if (found != null)
return found;
else
return FindInDerivedClass;
}

}


So the question is, as I need the name of the class that will inherit this
base clase, how do I get the value for the above <<<NameOfTheDerivedClass>>>?

Thank you.
 
public override string FindInDerivedClass
^^^^^^^^
I assume you mean abstract.

So the question is, as I need the name of the class that will inherit this
base clase, how do I get the value for the above <<<NameOfTheDerivedClass>>>?

this.GetType().Name should give you the name of the actual type of
your object.


Mattias
 
Thanks. I will try that out.

Mattias Sjögren said:
^^^^^^^^
I assume you mean abstract.



this.GetType().Name should give you the name of the actual type of
your object.


Mattias
 
Back
Top