I need to make fixed point number class inherit from System.Type.
class FixedPoint : Type
{
public bool Signed { get; set; }
public int Width { get; set; }
public int IntegerWidth { get; set; }
public FixedPoint(Boolean signed = false, int width = 16, int integerWidth = 8)
{
Signed = signed;
Width = width;
IntegerWidth = integerWidth;
}
}
When I tried to compile this code, I got error messages saying that I need to implement methods as Type is abstract class.
userdef.cs(3,7): error CS0534: 'FixedPoint' does not implement inherited abstract member 'System.Type.GUID.get'
userdef.cs(3,7): error CS0534: 'FixedPoint' does not implement inherited abstract member 'System.Type.Namespace.get'
c:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll: (Location of symbol related to previous error)
userdef.cs(3,7): error CS0534: 'FixedPoint' does not implement inherited abstract member
'System.Type.AssemblyQualifiedName.get'
How can I avoid those error messages? Is there any easy way to subclass Type? Do I have to implement all the methods? If so, are there any references for doing that?
Or
Is the work of subclassing Type worth trying? I do need to subclass Type for some reasons, if it’s really hard to do it. I’d better give up early to find another way.
You say you have your reasons for inheriting from
System.Type, even though I agree with @mootinator, here are some answers to your other questions:No.
Yes.
You add the
override-keyword to each of thePropertiesandMethodsThis is an example of how you start off, you need to
overrideeach of theabstractproperties and methods.This is a complete compileable
classthat overrides all thepropertiesandmethodsthat is needed, but nothing is implemented.These are the properties gets that you need to implement
These are the methods that you need to implement
As you can see, there are quite a few that you need to override in order to remove all the compilation errors, so either you have a really good reason for wanting to do this or you should think about overriding from another class/struct or just create a new class/struct.