Possible Duplicate:
Why does .Net Framework not use unsigned data types?
In The C# Programming Language (Covering C# 4.0) (4th Edition), 1.3 Types and Variables, Page 9.
Jon Skeet says;
Hooray for byte being an unsigned type! The fact that in Java a byte is signed (and with no unsigned equivalent) makes a lot of bit-twiddling pointlessly error-prone. It’s quite possible that we should all be using uint a lot more than we do, mind you: I’m sure many developers reach for int by default when they want an integer type. The framework designers also fall into this category, of course: Why should String.Length be signed?
When I decompile String.Length;
/// <summary>
/// Gets the number of characters in the current <see cref="T:System.String"/> object.
/// </summary>
///
/// <returns>
/// The number of characters in the current string.
/// </returns>
/// <filterpriority>1</filterpriority>
[__DynamicallyInvokable]
public int Length { [SecuritySafeCritical, __DynamicallyInvokable, MethodImpl(MethodImplOptions.InternalCall)] get; }
Also in MSDN;
The Length property returns the number of Char objects in this instance, not the number of Unicode characters. The reason is that a Unicode character might be represented by more than one Char.
It returns the number of character objects in the current string. Why does String.Length
return Int32
when there already is a type called UInt32
? What is the point of the signed-unsigned byte
and String.Length
?