Inherit from struct

.net, c#, inheritance, struct

Solution

A struct Is Implicitly Sealed

According to this link:

Every struct in C#, whether it is user-defined or defined in the .NET Framework, is sealed–meaning that you can’t inherit from it. A struct is sealed because it is a value type and all value types are sealed.

A struct can implement an interface, so it’s possible to see another type name following a colon, after the name of the struct.

In the example below, we get a compile-time error when we try to define a new struct that inherits from the one defined above.

public struct PersonName
{
    public PersonName(string first, string last)
    {
        First = first;
        Last = last;
    }

    public string First;
    public string Last;
}

// Error at compile time: Type 'PersonName' in interface list is not an interface
public struct AngryPersonName : PersonName
{
    public string AngryNickname;
}

Problem

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= str; } public string myString; } public struct MyStructB: MyStructA { public string myReversString; } ``` And i get this error: ``` Error at compile time: Type 'MyStructA' in interface list is not an interface ``` I don't understand why? the .net not implemnet struct like class?

Original source