I have a datatable customerTbl and I step through the rows
foreach (DataRow row in customerTbl.Rows)
{
string CustomerID = row["Customer ID"].ToString();
}
However, the column Customer ID returns byte[]. How can I convert this to a string (CustomerID)?
I tried something like
string CustomerID = Convert.ToBase64String(row["Customer ID"]);
but it obviously doesn’t work
Thanks in advance
Depending on the encoding of the bytes, you’d need the correct
Encodingobject to perform the conversion. Assuming it is ASCII, you can do this:If in a different encoding (UTF8, UTF16, etc.), use the appropriate one.