Skip to content

Instantly share code, notes, and snippets.

@jakl
Created January 11, 2011 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakl/775323 to your computer and use it in GitHub Desktop.
Save jakl/775323 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace kompiler
{
class fda
{
public enum state
{
/* 0*/
INIT = 0, ACCEPTCHAR, ACCEPTNUM, ETC
};
/* Doesn't compile; No overload for method 'Add' takes '1' arguments */
Dictionary<char, Dictionary<state, state>> students = new Dictionary<char, Dictionary<state, state>>()
{
{ 'l', new Dictionary <state, state> () {
state.INIT, state.INIT }
},
{ 'd', new Dictionary<state, state>(){
state.INIT, state.INIT }
},
{ '"', new Dictionary<state, state>(){
state.INIT, state.INIT }
}
};
}
}
@jakl
Copy link
Author

jakl commented Jan 11, 2011

There needs to be an extra set of {} around each of the { state, state }

Now the Dictionary declaration looks like this

Dictionary<char, Dictionary<state, state>> students = new Dictionary<char, Dictionary<state, state>>()
{
{ 'l', new Dictionary <state, state> () {
{state.INIT, state.INIT}
}
},
{ 'd', new Dictionary<state, state>(){
{ state.INIT, state.INIT }
}
},
{ '"', new Dictionary<state, state>(){
{ state.INIT, state.INIT }
}
}
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment