How to set null to a GUID property

后端 未结 8 1900
春和景丽
春和景丽 2020-12-16 10:25

I have an object of type Employee which has a Guid property. I know if I want to set to null I must to define my type property as nullable Nullable

相关标签:
8条回答
  • 2020-12-16 10:58

    I think this is the correct way:

    Guid filed = Guid.Empty;

    0 讨论(0)
  • 2020-12-16 11:05
    Guid? myGuidVar = (Guid?)null;
    

    It could be. Unnecessary casting not required.

    Guid? myGuidVar = null;
    
    0 讨论(0)
提交回复
热议问题