You can just use the Convert class as below.
///
/// Converts a string to byte array
///
/// The string
/// The byte array
public static byte[] ConvertToByteArray(string input)
{
return input.Select(Convert.ToByte).ToArray();
}
///
/// Converts a byte array to a string
///
/// the byte array
/// The string
public static string ConvertToString(byte[] bytes)
{
return new string(bytes.Select(Convert.ToChar).ToArray());
}
///
/// Converts a byte array to a string
///
/// the byte array
/// The string
public static string ConvertToBase64String(byte[] bytes)
{
return Convert.ToBase64String(bytes);
}