I have the following class with some methods and I would like to use this as a base class of another class.
public class BaseClass
{
public string DoWork(string str)
{
// some codes...
}
// other methods...
}
I don't want this class to be instantiated, but the derived class should still use the original implementation of the methods of its base class.
Is it possible? What should be my modifier?
Example SentencesIn “a red hat,” the adjective “red” is a modifier describing the noun “hat.” In “They were talking loudly,” the adverb “loudly” is a modifier of the verb “talking.”
Modifier BasicsA modifier is a word, phrase, or clause that modifies—that is, gives information about—another word in the same sentence. For example, in the following sentence, the word "burger" is modified by the word "vegetarian": Example: I'm going to the Saturn Café for a vegetarian burger.
As illustrated below, modifiers in English include adjectives, adverbs, demonstratives, possessive determiners, prepositional phrases, degree modifiers, and intensifiers. Modifiers that appear before the head are called premodifiers, while modifiers that appear after the head are called postmodifiers.
Since you don't want this class to be instantiated, make it an abstract
class. You can still have implementation on the class.
snippet,
public abstract class BaseClass
{
public virtual string DoWork(string str)
{
// can have implementation here
// and classes that inherits can overide this method because of virtual.
}
// other methods...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With