Inherit from struct

前端 未结 7 924
小蘑菇
小蘑菇 2020-12-16 13:07

I am try to figure out what is the problem whit my code. I have this code:

public struct MyStructA
{
    public MyStructA(string str)
    {
        myString=         


        
7条回答
  •  死守一世寂寞
    2020-12-16 13:18

    Struct does not support inheritance, if you need you have to use class, see msdn

    There is no inheritance for structs as there is for classes. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Structs, however, inherit from the base class Object. A struct can implement interfaces, and it does that exactly as classes do.

提交回复
热议问题