Scenario
How to convert a string or a string array into a double array?
The .NET does not provide any method for us to call directly(if you found it, please let me know :D). However this is easy to implement within just a couple lines of code.
Method
//Convert 1 string to an array of bytes
public static byte[] ConvertToBytes(string str)
{
byte[] ans = new byte[str.Length];
for (int i = 0; i < ans.Length; i++)
{
ans[i] = Convert.ToByte(str[i]);
}
return ans;
}
Subscribe to:
Post Comments (Atom)
comments
0 Responses to "C# Convert string to an array of bytes"Post a Comment