开发者

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

开发者 https://www.devze.com 2023-01-23 04:34 出处:网络
I recently converted a bunch of tables PK\'s from int to uniqueidentifier.Now in my code I am replacing certain checks like so:

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

精彩评论

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