Int32 Structure
Represents a 32-bit signed integer type.
The Int32
value type represents integers ranging from -2,147,483,648 through 2,147,483,647. The Int32
type is the most commonly used integral type in .NET. The System.Int32
structure has the following members:
- Object
- System.Int32
On This Page
Members
Fields (Constants)
-
public const int MaxValue
Represents the largest possible value of an
Int32
. This field is constant.public const int MaxValue = 2147483647;
-
public const int MinValue
Represents the smallest possible value of an
Int32
. This field is constant.public const int MinValue = -2147483648;
-
public const int SizeOf
The number of bytes used to store the value type.
public const int SizeOf = 4;
Fields
The Int32
structure does not declare any public fields.
Properties
The Int32
structure does not declare any public properties.
Methods
-
public int CompareTo(object value)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
- value
- An object to compare with this instance.
-
public int CompareTo(int value)
Compares the current instance with another
Int32
value and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other value.- value
- The
Int32
value to compare with this instance.
-
public bool Equals(object obj)
Returns a value indicating whether this instance is equal to a specified object.
- obj
- An object to compare with this instance.
-
public bool Equals(int obj)
Returns a value indicating whether this instance is equal to a specified
Int32
value.- obj
- The
Int32
value to compare with this instance.
-
public override int GetHashCode()
Returns the hash code for this instance.
-
public TypeCode GetTypeCode()
Returns the
TypeCode
for value typeInt32
. -
public string ToString()
Converts the value of this instance to its equivalent string representation.
-
public string ToString(IFormatProvider provider)
Converts the value of this instance to its equivalent string representation by using the specified culture-specific formatting information.
- provider
- An object that supplies culture-specific formatting information.
-
public static int Parse(string s)
Converts the string representation of a number to its 32-bit signed integer equivalent.
- s
- A string that represents the number to convert.
-
public static int Parse(string s, IFormatProvider provider)
Converts the string representation of a number to its 32-bit signed integer equivalent using specified culture-specific formatting information.
- s
- A string that represents the number to convert.
- provider
- An object that supplies culture-specific parsing information.
-
public static int Parse(string s, NumberStyles style)
Converts the string representation of a number to its 32-bit signed integer equivalent.
- s
- A string that represents the number to convert.
- style
- A bitwise combination of
NumberStyles
values that indicates the format ofs
. A typical value to specify isNumberStyles.Integer
.
-
public static int Parse(string s, NumberStyles style, IFormatProvider provider)
Converts the string representation of a number to its 32-bit signed integer equivalent using specified style and culture-specific format information.
- s
- A string that represents the number to convert.
- style
- A bitwise combination of
NumberStyles
values that indicates the format ofs
. A typical value to specify isNumberStyles.Integer
. - provider
- An object that supplies culture-specific parsing information.
-
public static bool TryParse(string s, out int result)
Converts the string representation of a number to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded or failed.
- s
- The string to convert.
- result
- When this method returns, contains the 32-bit signed integer value that is equivalent to the number contained in
s
, if the conversion succeeded, or zero if the conversion failed. Theout
parameter is assigned.
-
public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out int result)
Converts the string representation of a number to its 32-bit signed integer equivalent using specified style and culture-specific format information. A return value indicates whether the conversion succeeded or failed.
- s
- The string to convert.
- style
- A bitwise combination of
NumberStyles
values that indicates the format ofs
. A typical value to specify isNumberStyles.Integer
. - provider
- An object that supplies culture-specific parsing information.
- result
- When this method returns, contains the 32-bit signed integer value that is equivalent to the number contained in
s
, if the conversion succeeded, or zero if the conversion failed. Theout
parameter is assigned.
Operators
-
public static bool operator !=(int left, int right)
Determines whether two instances of
Int32
are not equal.- left
- The first instance to compare.
- right
- The second instance to compare.
-
public static bool operator <(int left, int right)
Compares two instances of
Int32
to determine which is less than the other.- left
- The first instance to compare.
- right
- The second instance to compare.
-
public static bool operator <=(int left, int right)
Compares two instances of
Int32
to determine which is less than or equal to the other.- left
- The first instance to compare.
- right
- The second instance to compare.
-
public static bool operator ==(int left, int right)
Determines whether two instances of
Int32
are equal.- left
- The first instance to compare.
- right
- The second instance to compare.
-
public static bool operator >(int left, int right)
Compares two instances of
Int32
to determine which is greater than the other.- left
- The first instance to compare.
- right
- The second instance to compare.
-
public static bool operator >=(int left, int right)
Compares two instances of
Int32
to determine which is greater than or equal to the other.- left
- The first instance to compare.
- right
- The second instance to compare.
-
public static implicit operator double(int value)
Converts an
Int32
value to adouble
value.- value
- The
Int32
value to convert.
-
public static implicit operator decimal(int value)
Converts an
Int32
value to adecimal
value.- value
- The
Int32
value to convert.
-
public static implicit operator float(int value)
Converts an
Int32
value to afloat
value.- value
- The
Int32
value to convert.
-
public static implicit operator long(int value)
Converts an
Int32
value to along
value.- value
- The
Int32
value to convert. -
public static implicit operator uint(int value)
Converts an
Int32
value to anuint
value.- value
- The
Int32
value to convert.
-
public static explicit operator sbyte(int value)
Converts an
Int32
value to ansbyte
value.- value
- The
Int32
value to convert.
-
public static explicit operator byte(int value)
Converts an
Int32
value to abyte
value.- value
- The
Int32
value to convert.
-
public static explicit operator short(int value)
Converts an
Int32
value to ashort
value.- value
- The
Int32
value to convert.
-
public static explicit operator ushort(int value)
Converts an
Int32
value to anushort
value.- value
- The
Int32
value to convert.
-
public static explicit operator char(int value)
Converts an
Int32
value to achar
value.- value
- The
Int32
value to convert.