Created
October 18, 2014 13:41
-
-
Save ertugrulozcan/d059df42266dd997df2b to your computer and use it in GitHub Desktop.
C# Dictionary Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
var words = new Dictionary<string, Dictionary<string, string[]>> | |
{ | |
{ | |
"TR", | |
new Dictionary<string, string[]> | |
{ | |
{"names", new string[] { "isim1", "isim2", "isim3" }}, | |
{"adjectives", new string[] { "sifat1", "sifat2", "sifat3" }} | |
} | |
}, | |
{ | |
"EN", | |
new Dictionary<string, string[]> | |
{ | |
{"names", new string[] { "name1", "name2", "name3" }}, | |
{"adjectives", new string[] { "adjective1", "adjective2", "adjective3" }} | |
} | |
} | |
}; | |
string language = "TR"; | |
int lengthOfNameList = words[language]["names"].Length; | |
int lengthOfAdjectiveList = words[language]["adjectives"].Length; | |
Random rand = new Random(); | |
Console.WriteLine("{0} {1}", words[language]["names"][rand.Next(lengthOfNameList)], words[language]["adjectives"][rand.Next(lengthOfAdjectiveList)]); | |
Console.ReadKey(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment