MongoDB.Bson.BsonUtils.ToHexString C# (CSharp) Method

ToHexString() public static method

Converts a byte array to a hex string.
public static ToHexString ( byte bytes ) : string
bytes byte The byte array.
return string
        public static string ToHexString(byte[] bytes)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException("bytes");
            }
            var sb = new StringBuilder(bytes.Length * 2);
            foreach (var b in bytes)
            {
                sb.AppendFormat("{0:x2}", b);
            }
            return sb.ToString();
        }

Usage Example

示例#1
0
 /// <summary>
 /// Returns a string representation of the value.
 /// </summary>
 /// <returns>A string representation of the value.</returns>
 public override string ToString()
 {
     return(BsonUtils.ToHexString(ToByteArray()));
 }
All Usage Examples Of MongoDB.Bson.BsonUtils::ToHexString