I recently converted a bunch of tables PK's from int
to uniqueidentifier
. Now in my code I am replacing certain checks like so:
if (planDiagnosisID != 0)
with
if (planDiagnosisID != Guid.Empty)
Where planDiagnosi开发者_JAVA百科sID is an int
in the first one and a Guid
in the second.
Is this accurate?
Yes that is correct. Guid.Empty is the default value for Guid. It is a value type, so it can't be null
.
Or in code
default(Guid) == Guid.Empty
Just as
default(int) == 0
精彩评论