I wrote a small C# program that saves an ordered map (SortedDictionary<int, string>) to a Bin. When reading it back, I see that the type is SortedDictionary<object, object>. Is there a way to have the C# client API return it as the same type that was used to populate the Bin?
I looked for a generic version of UnpackMap that allows the caller to specify TKey and TValue but I do not see one.
No. The server allows multiple key and value types in the same dictionary. The server returns each entry’s key and value type, but does not enforce a single key/value type for the entire dictionary. The client returns object entry types because it does not know in advance what the types will be.
It’s possible to cast SortedDictionary<object, object> to SortedDictionary<int, string> after receiving the dictionary, but that might have performance implications. See Cast Dictionary.