How can I achieve inheritance (or similar) with structs in C#? I know that an abstract struct isn\'t possible, but I need to achieve something similar.
I need it as
It looks like what you want is an interface.
public interface IVertex
{
int SizeInBytes { get; }
void SetPointers();
}
public struct ColorVertex : IVertex
{
private Vector3 Position;
private Vector4 Color;
public int SizeInBytes
{
get { return (3 + 4) * 4; }
}
public void SetVertexPointers() // Did you mean SetPointers?
{
}
}
An interface makes sense since all of your methods are declared abstract (this would mean it relies on deriving classes to implement the method which is essentially what an interface is)