I have certain scenarios (e.g. a custom class to hold Sql parameters) in which a variable may or may not be required. Traditionally I have always defined these being of type Guid?
and used myGuid.HasValue
to check for a valid value before using.
Of course in practice I could also use regular Guid
s and perform the check for valid value with myGuid == Guid.Empty
.
For readability I prefer the first usage as it feels cleaner but I would appreciate it if someone could advise on whether one of these methods is better (faster, quicker or more correct) than the other?