Struct int
Represents a 32-bit signed integer.
Inherited Members
Namespace: System
Assembly: mscorlib.dll
Syntax
public int
Fields
MaxValue
Represents the largest possible value of an Int32. This field is constant.
Declaration
public const int MaxValue = 2147483647
Field Value
Type | Description |
---|---|
int |
Remarks
The value of this constant is 2,147,483,647; that is, hexadecimal 0x7FFFFFFF.
MinValue
Represents the smallest possible value of Int32. This field is constant.
Declaration
public const int MinValue = -2147483648
Field Value
Type | Description |
---|---|
int |
Remarks
The value of this constant is -2,147,483,648; that is, hexadecimal 0x80000000.
Methods
Parse(string)
Converts the string representation of a number to its 32-bit signed integer equivalent.
Declaration
public static int Parse(string s)
Parameters
Type | Name | Description |
---|---|---|
string | s | A string containing a number to convert. |
Returns
Type | Description |
---|---|
int | A 32-bit signed integer equivalent to the number contained in s. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ToString()
Converts the numeric value of this instance to its equivalent string representation.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The string representation of the value of this instance, consisting of a negative sign if the value is negative, and a sequence of digits ranging from 0 to 9 with no leading zeroes. |
Overrides
ToString(string)
Converts the numeric value of this instance to its equivalent string representation, using the specified format.
Declaration
public string ToString(string format)
Parameters
Type | Name | Description |
---|---|---|
string | format | A standard or custom numeric format string |
Returns
Type | Description |
---|---|
string | he string representation of the value of this instance as specified by format. |
TryParse(string, out int)
Converts the string representation of a number to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded.
Declaration
public static bool TryParse(string s, out int result)
Parameters
Type | Name | Description |
---|---|---|
string | s | Converts the string representation of a number to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded. |
int | result | When this method returns, contains the 32-bit signed integer value equivalent of the number contained in |
Returns
Type | Description |
---|---|
bool |
Remarks
The TryParse(string, out int) method is like the Parse(string) method, except the TryParse(string, out int) method does not throw an exception if the conversion fails. It eliminates the need to use exception handling to test for a FormatException in the event that s
is invalid and cannot be successfully parsed.