Convert byte[] or object to GUID

前端 未结 5 1830
别那么骄傲
别那么骄傲 2021-02-12 10:20

I assigned some value to object data type like,

object objData =dc.GetDirectoryEntry().Properties[\"objectGUID\"].Value;

this object retun the

5条回答
  •  孤城傲影
    2021-02-12 11:12

    The long form would be (enter link description here):

    public static string ConvertGuidToOctectString(string objectGuid)
    {
        System.Guid guid = new Guid(objectGuid);
        byte[] byteGuid = guid.ToByteArray();
        string queryGuid = "";
        foreach (byte b in byteGuid)
        {
            queryGuid += @"\" + b.ToString("x2");
        }
        return queryGuid;
    }
    

提交回复
热议问题