Is there a way to use out
on uninitialized object properties?
Ex:
QuoteDetail q = new QuoteDetail();
Dictionary<int, string> messageDict = SplitMessage(msg);
messageDict.TryGetValue(8, out q.QuoteID); //doesn't work
Is there a way to use out
on uninitialized object properties?
Ex:
QuoteDetail q = new QuoteDetail();
Dictionary<int, string> messageDict = SplitMessage(msg);
messageDict.TryGetValue(8, out q.QuoteID); //doesn't work
No, you won't be able to do that. Just use a temporary variable instead:
QuoteDetail q = new QuoteDetail();
Dictionary<int, string> messageDict = SplitMessage(msg);
string quoteID;
if (messageDict.TryGetValue(8, out quoteID))
{
q.QuoteID = quoteID;
}
Simple answer: NO
You can't use properties. You will have to use a variable instead
BTW: has been answered a dozen times already: Passing a property as an 'out' parameter in C#
You have to initiate the out parameter.
The following link from msdn should help...