为什么 .NET 不对 DateTime.Month 和 DateTime.Year 之类的东西使用无符号整数类型?

Why doesn't .NET use unsigned integer types for things like DateTime.Month and DateTime.Year?

为什么 .NET 不使用像 uint(UInt32) or ushort (UInt16) for properties that cannot be negative, like DateTime.Year and DateTime.Month 这样的无符号整数类型。事实上,在我的记忆中,我从未见过它们在 FCL 中使用过。我们什么时候 应该使用它们?

引用“Language Independence and Language-Independent Components

The .NET Framework is language independent. This means that, as a developer, you can develop in one of the many languages that target the .NET Framework, such as C#, C++/CLI, Eiffel, F#, IronPython, IronRuby, PowerBuilder, Visual Basic, Visual COBOL, and Windows PowerShell. You can access the types and members of class libraries developed for the .NET Framework without having to know the language in which they were originally written and without having to follow any of the original language's conventions. If you are a component developer, your component can be accessed by any .NET Framework app regardless of its language.

并非所有语言都支持无符号整数,因此在 public 或受保护方法中使用无符号整数会使您的代码不符合 CLS。您可以在私人和内部成员上使用它们,但不能在 public 或受保护的成员上使用。因此,.NET 框架试图使其所有 public 方法和成员都符合 CLS,因此它们可以在任何语言中使用。