C# create a synonymous type for System.Single with a subset of features

80 Views Asked by At

I want to create a type that is basically equivalent to System.Single, but with a subset of features. The reason for this is I have algorithms that emit timestamps in System.Single and I want to add extension methods to work with the results.

It would be inappropriate to add Method(this float a) as invalid values could be passed in.

I looked at the System.Single source code here. However, I don't understand why there's no constructor or setter of any sort. I checked a few of the other base value types and none of them have any visible method of setting the value.

How is this possible?

The reason I ask is I want my new type to be operable in the same way as the base types, so I want to create a type with the same behavior.

0

There are 0 best solutions below