I’m using a uint
type as a unique ID for objects. For readability and changeability purposes, I’d rather not use a uint
but an alias that would evaluate as uint. Usually, I’d add a using
clause and then use the defined type:
using ObjId = System.UInt32
class MyObj {
public ObjId Id {get; private set;}
}
Correct me if I’m mistaken, but if I’d use the code above, it would convert all the Ids to reference types instead of primitives, which could have a negative impact on performance. What I’d really like to do is using ObjId = uint
, but that doesn’t seem to work.
Is there any way to achieve what I want? I’d like to get all the performance benefits of using a primitive, but have the readability and mistake-proof benefits of using a more strongly typed variable (for example, if I decide to change it to a GUID in the future, I’d be able to easily find all occurances by searching for ObjId, whereas searching for uint would be much less helpful).