c# - Simulate deriving from a value type -
c# - Simulate deriving from a value type -
i building calculator, , have type called buttondigit, may contain chars 0 9, , phone call buttondigit'. ideally derived fromchar`, isn't allowed, , don't want object like:
public class buttonchar { public char value { get; set; } } i find rather clumsy having instantiate buttonchar object , access value property when want character stored. ideal type of alias char set 0-9, don't that. stuck buttonchar object, or plain char , checking it's in range?
char struct, can't inherit it. custom buttonchar class decent approach though.
another approach create bunch of char constants
public static class myconstants { public static char zero{get{return '0';}} .... } the range comparing easy since it's sequential range 0-9
c# class inheritance set alias
Comments
Post a Comment