Tries to parse string to Byte
using System;
public class ByteConversion
{
public static void Main()
{
string byteString = "0x1F";
CallTryParse(byteString);
}
private static void CallTryParse(string stringToConvert)
{
byte byteValue;
bool result = Byte.TryParse(stringToConvert, out byteValue);
if (result)
{
Console.WriteLine("Converted '{0}' to {1}", stringToConvert, byteValue);
}
}
}
Related examples in the same category