how to convert byte[100] to guid
I am receiving a service response which is byte[100]
how can i convert it to a guid ?
byte[] response = wc.UploadValues(url, "POST", nvc);
string Guid = new Guid(response).ToStri开发者_运维技巧ng();
Response.Write(Guid);
There is a Guid constructor which allows you to initialize a Guid from a 16-element byte array. So you will have to first extract the 16 elements from your 100 elements array into a new one and then initialize the Guid. Which 16 elements to extract from your 100 elements array would of course depend.
Now I suspect that what happens here is that the server sends the Guid as a string in the response. So all you have to do is parse it after converting the response from the server into a string using the proper encoding:
byte[] response = wc.UploadValues(url, "POST", nvc);
var guid = Guid.Parse(Encoding.UTF8.GetString(response));
I don't fully understand your code snippet, but Guid has overloads for new (byte[]) and a ToByteArray Method to transform Guids from and into Byte-Arrays - that should do the trick
精彩评论