Convert unique id to string

How can I convert the result of the GetUniqueId function to a string?

DeviceInformation.GetUniqueId()
            var uni = DeviceInformation.GetUniqueId();
            var stru = "";

            for (var i = 0; i < uni.Length; i++)
            {
                stru += uni[i].ToString("x2") + " ";
            }

            Debug.WriteLine("uni :" + stru);

I thought there was a one line way.
Thanks for the snippet.

You can put all of them in one line :))).

4 Likes

You can use BitConverter.ToString

var id = DeviceInformation.GetUniqueId();
Trace.WriteLine(BitConverter.ToString(id));
3 Likes

Perfect. That 's what I was looking for. Thank you!