I\'m making a call:
myResult = MakeMyCall(inputParams, out messages);
but I don\'t actually care about the messages. If it was an input pa
You must pass a variable for the out parameter. You do not have to initialize the variable before passing it:
MyMessagesType messages;
myResult = MakeMyCall(inputParams, out messages);
Typically, you can just ignore 'messages' after the call - unless 'messages' needs disposing for some reason, such as the use of limited system resources, in which case you should call Dispose():
messages.Dispose();
If it might use a significant amount of memory and it is going to remain in scope for a while, it should probably be set to null if it is a reference type or to a new default instance if it's a value type, so that the garbage collector can reclaim the memory:
messages = null; // Allow GC to reclaim memory for reference type.
messages = new MyMessageType(); // Allow GC to reclaim memory for value type.
In this case I made an generic extension method for ConcurrentDictionary that has no Delete or Remove method.
//Remove item from list and ignore reference to removed item
public static void TryRemoveIgnore<K,T>(this ConcurrentDictionary<K,T> dictionary, K key)
{
T CompletelyIgnored;
dictionary.TryRemove(key, out CompletelyIgnored);
}
When called from an instance of ConcurrentDictionary:
ClientList.TryRemoveIgnore(client.ClientId);