Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would be the right modifier?

Tags:

c#

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?

like image 508
yonan2236 Avatar asked Sep 23 '13 10:09

yonan2236


People also ask

What are examples of modifiers?

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.”

What is correct modifier wording?

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.

What are the 5 modifiers?

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.


1 Answers

Since you don't want this class to be instantiated, make it an abstract class. You can still have implementation on the class.

  • abstract

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...
}
like image 114
John Woo Avatar answered Sep 29 '22 00:09

John Woo