Converting string to byte array in C# -


i'm quite new c#. i'm converting vb c#. having problem syntax of statement:

if ((searchresult.properties["user"].count > 0)) {     profile.user = system.text.encoding.utf8.getstring(searchresult.properties["user"][0]); } 

i see following errors:

argument 1: cannot convert 'object' 'byte[]'

the best overloaded method match 'system.text.encoding.getstring(byte[])' has invalid arguments

i tried fix code based on this post, still no success

string user = encoding.utf8.getstring("user", 0); 

any suggestions?

if have byte array need know type of encoding used make byte array.

for example, if byte array created this:

byte[] tobytes = encoding.ascii.getbytes(somestring); 

you need turn string this:

string = encoding.ascii.getstring(tobytes); 

if can find in code inherited, encoding used create byte array should set.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -