Hello
I have a method that converts a string to byte array but an ArgumentException is thrown when I try to instantiate an attribute with the value returned by the method. I get this message: "Cannot convert object of type 'System.Byte[]' to object of type 'System.String'."
I don't get why this is happening, the attribute is of type byte[] and the returned value is also a byte[]
The code is:
byte[] bytes = GetBytes(cn.Senha);
scsb.Password = bytes
private byte[] GetBytes(string str)
{
byte[] bytes = new byte[str.Length * sizeof(char)];
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
return bytes;
}
Please help
thanks