namespace System {
- public struct Char : IComparable { //, IFormattable, IConvertible {
+ [Serializable]
+ public struct Char : IComparable, IConvertible { //, IFormattable {
public const char MaxValue = (char) 0xffff;
public const char MinValue = (char) 0;
throw new ArgumentNullException (Locale.GetText ("str is a null reference"));
if (index < 0 || index >= str.Length)
- throw new ArgumentOutOfRangeException (Locale.GetText ("The value of index is less than zero, or greater than or equal to the length of str"));
+ throw new ArgumentOutOfRangeException (Locale.GetText ("The value of index is less "+
+ "than zero, or greater than or equal to the length of str"));
return GetUnicodeCategory (str[index]);
}
if (index < 0 || index >= str.Length)
throw new ArgumentOutOfRangeException (Locale.GetText (
- "The value of index is less than zero, or greater than or equal to the length of str"));
+ "The value of index is less than zero, or greater than or equal to the length of str"));
return IsDigit (str[index]);
}
if (index < 0 || index >= str.Length)
throw new ArgumentOutOfRangeException (Locale.GetText (
- "The value of index is less than zero, or greater than or equal to the length of str"));
+ "The value of index is less than zero, or greater than or equal to the length of str"));
return IsLetter (str[index]);
}
if (index < 0 || index >= str.Length)
throw new ArgumentOutOfRangeException (Locale.GetText (
- "The value of index is less than zero, or greater than or equal to the length of str"));
+ "The value of index is less than zero, or greater than or equal to the length of str"));
return IsLetterOrDigit (str[index]);
}
-
+
[MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
public static extern bool IsLower (char c);
if (index < 0 || index >= str.Length)
throw new ArgumentOutOfRangeException (Locale.GetText (
- "The value of index is less than zero, or greater than or equal to the length of str"));
+ "The value of index is less than zero, or greater than or equal to the length of str"));
return IsLower (str[index]);
}
if (index < 0 || index >= str.Length)
throw new ArgumentOutOfRangeException (Locale.GetText (
- "The value of index is less than zero, or greater than or equal to the length of str"));
+ "The value of index is less than zero, or greater than or equal to the length of str"));
return IsNumber (str[index]);
}
if (index < 0 || index >= str.Length)
throw new ArgumentOutOfRangeException (Locale.GetText (
- "The value of index is less than zero, or greater than or equal to the length of str"));
+ "The value of index is less than zero, or greater than or equal to the length of str"));
return IsPunctuation (str[index]);
}
if (index < 0 || index >= str.Length)
throw new ArgumentOutOfRangeException (Locale.GetText (
- "The value of index is less than zero, or greater than or equal to the length of str"));
+ "The value of index is less than zero, or greater than or equal to the length of str"));
return IsSeparator (str[index]);
}
if (index < 0 || index >= str.Length)
throw new ArgumentOutOfRangeException (Locale.GetText (
- "The value of index is less than zero, or greater than or equal to the length of str"));
+ "The value of index is less than zero, or greater than or equal to the length of str"));
return IsSurrogate (str[index]);
}
if (index < 0 || index >= str.Length)
throw new ArgumentOutOfRangeException (Locale.GetText (
- "The value of index is less than zero, or greater than or equal to the length of str"));
+ "The value of index is less than zero, or greater than or equal to the length of str"));
return IsUpper (str[index]);
}
if (str == null)
throw new ArgumentNullException (Locale.GetText ("str is a null reference"));
- int len = str.Length;
- if (len != 1){
- if (len < 1)
- throw new ArgumentNullException ();
- else
- throw new FormatException ();
- }
+ if (str.Length != 1)
+ throw new FormatException ("string contains more than one character.");
+
return str [0];
}
{
return TypeCode.Char;
}
+
+ object IConvertible.ToType (Type conversionType, IFormatProvider provider)
+ {
+ return System.Convert.ToType(value, conversionType, provider);
+ }
+
+ bool IConvertible.ToBoolean (IFormatProvider provider)
+ {
+ throw new InvalidCastException();
+ }
+
+ byte IConvertible.ToByte (IFormatProvider provider)
+ {
+ return System.Convert.ToByte(value);
+ }
+
+ char IConvertible.ToChar (IFormatProvider provider)
+ {
+ return value;
+ }
+
+ [CLSCompliant(false)]
+ DateTime IConvertible.ToDateTime (IFormatProvider provider)
+ {
+ throw new InvalidCastException();
+ }
+
+ decimal IConvertible.ToDecimal (IFormatProvider provider)
+ {
+ throw new InvalidCastException();
+ }
+
+ double IConvertible.ToDouble (IFormatProvider provider)
+ {
+ throw new InvalidCastException();
+ }
+
+ short IConvertible.ToInt16 (IFormatProvider provider)
+ {
+ return System.Convert.ToInt16(value);
+ }
+
+ int IConvertible.ToInt32 (IFormatProvider provider)
+ {
+ return System.Convert.ToInt32(value);
+ }
+
+ long IConvertible.ToInt64 (IFormatProvider provider)
+ {
+ return System.Convert.ToInt64(value);
+ }
+
+ [CLSCompliant(false)]
+ sbyte IConvertible.ToSByte (IFormatProvider provider)
+ {
+ return System.Convert.ToSByte(value);
+ }
+
+ float IConvertible.ToSingle (IFormatProvider provider)
+ {
+ throw new InvalidCastException();
+ }
+
+ string IConvertible.ToString (IFormatProvider provider)
+ {
+ return ToString(provider);
+ }
+
+ [CLSCompliant(false)]
+ ushort IConvertible.ToUInt16 (IFormatProvider provider)
+ {
+ return System.Convert.ToUInt16(value);
+ }
+
+ [CLSCompliant(false)]
+ uint IConvertible.ToUInt32 (IFormatProvider provider)
+ {
+ return System.Convert.ToUInt32(value);
+ }
+
+ [CLSCompliant(false)]
+ ulong IConvertible.ToUInt64 (IFormatProvider provider)
+ {
+ return System.Convert.ToUInt64(value);
+ }
}
}