I’m writing a system that has a set of protocol buffers (using protobuf-net), I want to define something like this in an abstract class they all inherit off:
public byte[] GetBytes()
however, the protocol buffer serealiser requires a type argument, is there some efficient way to get the type of the inheriting class?
Example:
public byte[] GetBytes()
{
using (MemoryStream stream = new MemoryStream())
{
Serializer.Serialize<T /* what goes here? */>(stream, this);
return stream.ToArray();
}
}
Just write “T” right?
and then in your class declaration:
?
— Edit
And then when you inherit it: