Inherit from struct

前端 未结 7 954
小蘑菇
小蘑菇 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:24

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

    But remember, since structs are a value type and they inherit System.ValueType

提交回复
热议问题