There are several circumstances which will display this output (or exception in some cases) in .NET, however the primary reason is because there is a mismatch between the expected format and the casting taking place in your application. An example would be attributes which are bound to LDAP that do not readily cast to string.
Here is a quick solution (that has its roots in vc++) for successfully casting this datatype to string:
byte[] myByteArray = (byte[])result.Properties["memberOf"][counter];
string myString = "";
foreach (byte b in myByteArray)
{
char singleChar = Convert.ToChar(b);
myString += singleChar.ToString();
}
I just received some feedback from Joe. He was kind enough to offer alternative code:
byte [] bytes = Encoding.ASCII.GetBytes("This is a test");
String s = Encoding.ASCII.GetString(bytes);