Mono Class Library: System.Byte Overview | MembersSystem.Byte.Parse Method |
Returns the specified string converted to a byte value. [Edit]
|
- s
- A string containing the value to convert. The string is interpreted using the System.Globalization.NumberStyles.Integer style. [Edit]
The byte value obtained from s. [Edit]
Type Reason ArgumentNullException s is a null reference. [Edit] FormatException s is not in the correct style. [Edit] OverflowException s represents a number greater than byte.MaxValue or less than byte.MinValue. [Edit]
This version of byte.Parse(string) is equivalent to byte.Parse(string) (s, System.Globalization.NumberStyles.Integer , null ).
The string s is parsed using the formatting information in a System.Globalization.NumberFormatInfo initialized for the current system culture.
Note: For more information, see System.Globalization.NumberFormatInfo.CurrentInfo.[Edit]
The following example demonstrates the byte.Parse(string) method.
C# Example using System; public class ByteParseClass { public static void Main() { string str = " 100 "; Console.WriteLine("String: \"{0}\" <Byte> {1}",str,Byte.Parse(str)); } }The output is
String: " 100 " <Byte> 100
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0