When i do val = dict["nonexistent key"] i get System.Collections.Generic.KeyNotFoundException
Is there a way i have my dictionary call a member function with the key as a param to generate a value?
-edit-
Maybe i should of been more specific. I want to AUTOMATICALLY call a member function to do what it needs create the proper value for ...
Hi there.
I got a little problem. Sometimes, when I try to call the following code, the remove methods throw an exception with the message "the key is not present in the dictionary".
private Dictionary<IPAddress, ARPHostEntry> dIPHostTable;
private Dictionary<MACAddress, ARPHostEntry> dMACHostTable;
public HostTable()
{
dIPHostTab...
I've been building an extensions library, and I've utilised a great extension method found at http://www.extensionmethod.net for inclusion. In my unit test (using NUnit 1.5.2), I've come across an interesting issue. Firstly, lets look at the code:
/// <summary>
/// Groups and aggregates the sequence of elements.
/// </summ...
I've got the following code where for some reason I'm getting a KeyNotFoundException even though I'm using a key that I had retrived a couple of lines above. Does anyone know of a situation where this wouldn't work? I'm stumped. BTW 'SchemaElementType is an enum.
public class DefaultValue
{
private Dictionary<Parameter, string> _para...
Hi,
I have a Helper Method in my View which renders the whole form dynamically. Now i want to add a support for Client Validation as available in Asp.Net MVC RC 2.
Following is the code i use to render Validation Summary field onto the Form.
_viewPage.Html.EnableClientValidation();
MvcHtmlString validationSummary = _viewPage.H...
I could have sworn that I've used NUnit's Assert.Throws to determine whether or not a particular exception gets thrown from a method, but my memory has failed me before. I read this post here on SO, but it didn't answer my question, as I know the correct syntax, and I don't want to do anything with the exception that gets returned (I do...
I'm about ready to bang my head against the wall
I have a class called Map which has a dictionary called tiles.
class Map
{
public Dictionary<Location, Tile> tiles = new Dictionary<Location, Tile>();
public Size mapSize;
public Map(Size size)
{
this.mapSize = size;
}
//etc...
I fill this dictionary tem...