开发者

myVariable(int) == 0 same as myVariable(Guid) == Guid.Empty

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜