While reading the MongoDB Driver code. I noticed an enum with all its values as hexadecimal. I have seen this before but never asked myself why hexadecimal is the best choice. Now I am trying to further myself and understand this piece of code and the reasons MongoDB went the hhexadecimal route instead of intergers. Any help will be appreciated.
Here is the code I am referring to:
https://github.com/mongodb/mongo-csharp-driver/blob/master/src/MongoDB.Bson/ObjectModel/BsonType.cs
Code snippet:
namespace MongoDB.Bson
{
[Serializable]
public enum BsonType
{
EndOfDocument = 0x00,
Double = 0x01,
String = 0x02,
Document = 0x03,
Array = 0x04,
Binary = 0x05,
Undefined = 0x06,
ObjectId = 0x07,
Boolean = 0x08,
DateTime = 0x09,
Null = 0x0a,
RegularExpression = 0x0b,
JavaScript = 0x0d,
Symbol = 0x0e,
JavaScriptWithScope = 0x0f,
Int32 = 0x10,
Timestamp = 0x11,
Int64 = 0x12,
MinKey = 0xff,
MaxKey = 0x7f
}
}