Mega Code Archive

 
Categories / C# Tutorial / Data Type
 

Family of Integers

C# defines nine integer types: char, byte, sbyte, short, ushort, int, uint, long, ulong. char type is used for representing characters The integer structures are Byte SByte Int16 UInt16 Int32 UInt32 Int64 UInt64 The integer structures also define the following const fields: MaxValue MinValue Methods Supported by the Integer Structures MethodMeaning public int CompareTo(object v)Returns 0 if the values are equal. Returns a negative value if the invoking object has a lower value. Returns a positive value if the invoking object has a greater value. public override bool Equals(object v)Returns true if equal. public override int GetHashCode()Returns the hash code. public TypeCode GetTypeCode()Returns the TypeCode enumeration value. For example, for Int32, the type code is TypeCode.Int32. public static retType Parse(string str)Parses the string. public static retType Parse(string str,IFormatProvider fmtpvdr)Parse string using the culture-specific information provided by fmtpvdr. public static retType Parse(string str, NumberStyles styles)Parse string using the style information provided by styles. public static retType Parse(string str, NumberStyles styles,IFormatProvider fmtpvdr)Parse string using the style information provided by styles and the culture-specific format information provided by fmtpvdr. public override string ToString()Convert value to string. public string ToString(string format)Convert value to string as specified by the format string. public stringToString(IFormatProvider fmtpvdr)Returns the string representation of the value of the invoking object using the culture-specific information. public stringToString(string format,IFormatProvider fmtpvdr)Returns the string representation of the value of the invoking object using the culture-specific information and the format. All of the integer structures implement the following interfaces: IComparable, IConvertible, and IFormattable.