Re: Dictionary class lacks the very basic function ?
- From: Mattias Sjögren <mattias.dont.want.spam@xxxxxxxx>
- Date: Fri, 22 Sep 2006 21:24:15 +0200
I want to use Dictionary class like this:
textboxM.Text = oMyDict.GetValue("textboxM");
textboxN.Text = oMyDict.GetValue("textboxN");
Where my dictionary contains the list of values for my textbox based on
the textbox id.
But it doesn't have it !
Use the indexer
textboxM.Text = oMyDict["textboxM"];
TryGetValue !? What's that ? Why I have to provide an out parameter,
isn't more simple just return the value or null if not found !?
A Dictionary can be instantiated with a value type that isn't
nullable, so returning null isn't always an option. That's why
TryGetValue is needed.
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
.
- Follow-Ups:
- Re: Dictionary class lacks the very basic function ?
- From: craigkenisston
- Re: Dictionary class lacks the very basic function ?
- References:
- Dictionary class lacks the very basic function ?
- From: craigkenisston
- Dictionary class lacks the very basic function ?
- Prev by Date: Re: Dictionary class lacks the very basic function ?
- Next by Date: Refresh problem?
- Previous by thread: Re: Dictionary class lacks the very basic function ?
- Next by thread: Re: Dictionary class lacks the very basic function ?
- Index(es):
Relevant Pages
|