简体   繁体   中英

Calling base method from two different derived classes C#

I am new to OOP and this question might be easy but could not find an answer to it. any help would be great!

If I have a base class A that has a method called DoAction()

base class A
{
    void DoAction(string s)
    {
       print s;
    }
}

I also have two derived classes B and C

derived class B : A
{
    string b = "I am in B class";
    base.DoAction(b);
}

derived class C : A
{
    string c = "I am in C class";
    base.DoAction(c);
}

My question is if the DoAction() method from the base class get called from both derived classes (( at the same time )), will my code counter any issues at run time? Or does each derived class has its own copy of the base method?

Does the same concept applied to events in the base class? I mean if I call the same event from two different derived classes at the same time.

Thank you

只要代码不依赖于同一条数据,就不会遇到任何问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM