Dictionary<string,string> example = new Dictionary<string,string>(); ... example.Add("hello","world"); ... Console.Writeline(example["hello"]);
function Dictionary(){ var dictionary = {}; this.setData = function(key, val) { dictionary[key] = val; } this.getData = function(key) { return dictionary[key]; } } var dictionary = new Dictionary(); dictionary.setData("key1", "value1"); var key1 = dictionary.getData("key1");
members.AddRange(type.GetProperties().Where(p => p.CanRead && p.CanWrite && p.GetIndexParameters().Length == 0)); Dictionary<string, object> values = new Dictionary<string, object>();
public static void main(String[] args) throws FileNotFoundException { d = new Dictionary("H:\\csc8001\\results.txt"); d.outputToFile("H:\\csc8001\\results1.txt"); }
class LongLivedObject { private Dictionary <string, string> _settings; public LongLivedObject(Dictionary <string, string> settings) { // In C# this always duplicates the data structure and takes O(n) time. // C++ will automatically try to decide if it could do a swap instead. // C++ always lets you explicitly say you want to do the swap. _settings = new Dictionary <string, string>(settings); } }
Dictionary<string, object> dataResult = new Dictionary<string, object>(); dataResult["data"] = new List<object[]>(); dataResult["name"] = i; foreach (var item in query) { object[] values = new object[2]; values[0] = Convert.ToDecimal(item.ini) ; values[1] = Convert.ToDecimal(item.ir); ((List<object[]>)dataResult["data"]).Add(values); }
Dictionary<OperatorType, string> operators = new Dictionary<OperatorType, string>(); operators.Add(OperatorType.GreaterOrEqual, "Greater or equal"); Console.WriteLine(operators[OperatorType.GreaterOrEqual]); //"Greater or equal" OperatorType operatorType = 1; Console.WriteLine(operatorType.name); //"Greater"
static void Main(string[] args) { Dictionary<String, double[]> dict = new Dictionary<string, double[]>(); dict.Add("Values1", new double[] { 0.0, 2.33, -3, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 }); dict.Add("Values2", new double[] { 1.0, 2.0, 0.0, 1.567207, 0.0, 2.224827, 0.2, 0.0, 1.0 }); dict.Add("Values3", new double[] { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -3.222, 1.2209, 0.0 }); }
Dictionary<WallLocations, Image> map = new Dictionary<WallLocations, Image>(); map.Add(WallLocations.None, image0000); map.Add(WallLocations.Left, image1000); map.Add(WallLocations.Right, image0100); map.Add(WallLocations.Top, image0010); map.Add(WallLocations.Bottom, image0001); map.Add(WallLocations.Left | WallLocations.Right, image1100); // ....
function Dictionary(){ var dictionary = {}; this.setData = function(key, val) { dictionary[key] = val; } this.getData = function(key) { return dictionary[key]; } } var dictionary = new Dictionary(); dictionary.setData("key1", "value1"); var key1 = dictionary.getData("key1");
public Dictionary<MyEnum, Quad> my_quads = new Dictionary<MyEnum, Quad>(); public static enum MyEnum { Resource1 = 0 Resource2 = 1 Resource3 = 2 } public Quad getQuad(MyEnum resource_index) { return my_quads[resource_index]; }
Dictionary dict = new Dictionary(); dict.insert("word", new Integer(42)); Object count = dict.find("word"); // gives an Object, not an Integer // need to cast - annoying, not safe Integer countAsInteger = (Integer)count;
Dictionary dic = new Dictionary(); if (!dic.find("some")) { dic.add("Porto"); System.out.println("'some' added"); } if (!dic.find("something")) { dic.add("Porto"); System.out.println("'something' added"); }
Dictionary myDict = new HashTable<string, string>(); InputStream wordDictionary = getResources().openRawResource(R.raw.wordDictionary); DataInputStream myDIS = new DataInputStream(wordDictionary); ArrayList<string> lines = new ArrayList<Lines>(); string currLine; //Read document into arraylist: while((myLine=myDIS.readline())!=null) list.add(myLine); //Take each line, add left word as key, add right word as value: foreach(line : lines){ myDict.add(line.substring(0, line.indexOf(" ")), line.substring(line.indexOf(" ", line.indexOf(" ")+1)); }
Dictionary download = new Dictionary(); download["default_directory"] = "/path/to/dir"; Dictionary prefs = new Dictionary(); prefs["browser"] = download; DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability("chrome.prefs", prefs); WebDriver driver = new ChromeDriver(capabilities);
HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(url); HttpResponse response = null; Dictionary<String, String> postFields = new Dictionary<String, String>(); // Set the post fields postFields.add("username","toto"))); postFields.add("password", "thePassword45155"))); post.setEntity(new UrlEncodedFormEntity(postFields, HTTP.UTF_8)); // Execute the POST request response = client.execute(post);
Dictionary labelTable = new Dictionary(); labelTable.put(new Integer(0), new JLabel("Stop")); labelTable.put(new Integer(FPS_MAX / 10), new JLabel("Slow")); labelTable.put(new Integer(FPS_MAX), new JLabel("Fast")); framesPerSecond.setLabelTabel(labelTable);
Dictionary<string, string> valueList = new Dictionary<string, string>(); valueList.Add("M", "Male"); valueList.Add("F", "Female"); var jsonSerialiser = new JavaScriptSerializer(); var json = jsonSerialiser.Serialize(new { values: valueList }); return json;
dynamic expando = new ExpandoObject(); expando.hello = "hi"; expando.goodbye = "cya"; var dictionary = new Dictionary<string, object>(expando); return this.Json(dictionary); // or new JsonResult { Data = dictionary };
Dictionary dict = new Dictionary(new File("PATH/dict")); dict.open(); WordnetStemmer stemmer = new WordnetStemmer(dict); List<String> test = stemmer.findStems("feet", POS.NOUN); for (int i = 0; i < test.size(); i++) { System.out.println(test.get(i)); }