I'm trying to find you what is the 'point' of specifying a base type in an enum? What is the benefit of using...over...Code:enum State : int // note the 'int' { Initialise = -1, Process = 0, Finalise = 1 }One incorrect assumption that I made was to assume you would be able to do...Code:enum State { Initialise = -1, Process = 0, Finalise = 1 }but it seems you still need to cast...Code:Stage currentStage = Stage.Initialise; int databaseField = currentStage; // ultimately a field in a DataTable of type SqlDbType.IntSo what is the reason for specifying a base type?Code:Stage currentStage = Stage.Initialise; int databaseField = (int)currentStage;
I do realise the 'int' is the default, I'm just talking in general. All I can think of is compiler optimisation or early binding of errors maybe...




Reply With Quote