C# Enums: Nullable or 'Unknown' Value?

前端 未结 6 1120
生来不讨喜
生来不讨喜 2020-12-01 07:12

If I have a class with an enum member and I want to be able to represent situations where this member is not defined, which is it better?

a) Declare the

6条回答
  •  既然无缘
    2020-12-01 07:32

    I agree with archimed7592 that there is a real difference between absent value and "Unknown" value.

    Example:

    "what is your blood type?"

    • Null = absent value --> question hasn't been answered --> ask the question

    • "Unknown" --> patient indicates he doesn't know --> order lab test for the blood type

提交回复
热议问题