Take the following code to expose A:
string sql; if (!GetQueries.TryGetValue(type.TypeHandle, out sql))
The documentation for the dictionary says that if the key is not found, the link type will be null. Ok, that's fine.
If the key is found, how is the 'sql' variable populated? Is the key value found cloned? Is the type of the object for the item found and then the contents of the object copied? It is safe?
Or, to set the location for the outgoing object to be located, you should set the call as exhibit B:
var sql = string.Empty; if (!GetQueries.TryGetValue(type.TypeHandle, out sql))
Then the variable 'sql' is initialized and there is a safe place for the object.
(My question comes from my disgust with null pointers in C programming days.)
source share