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

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -