C# .NET: Is it possible to create compile time warnings when property is set to invalid values?

后端 未结 2 1520
傲寒
傲寒 2021-01-19 05:34

This is just a feasibility question. I know that if I say

   int myInt = \"5\"; 

I get a compile time error. What I want to do is create

相关标签:
2条回答
  • 2021-01-19 06:20

    Here is a question that covers the same topic. The accepted answer suggests that you use code contracts.

    0 讨论(0)
  • 2021-01-19 06:30

    No, not with just C#. Microsoft's Code Contracts work may give you what you want: http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx.

    0 讨论(0)
提交回复
热议问题