user7190976 user7190976 - 16 days ago 8
C# Question

print OrderedDictionary array values?

Line: gets one line from the file, it's iterate

string[] values = line.split(","); // ex: ["hi, "test", "no", "sup"]

OrderedDictionary od = new OrderedDictionary();
Tuple<int, string[]> innerTuple = new Tuple<int, string[]>(int.Parse(value[0], values);


I cannot seem to find a way to print out the value array. However, I can print out the arrays by using regular dictionary (I don't like how dictionary can mix up the order of insertion).

Answer

Try with this:

foreach (DictionaryEntry item in od)
{
    Console.WriteLine(item.Key);
    Console.WriteLine(item.Value);
}

UPDATE:

If you have a string array as the value then you should try something like this:

foreach (DictionaryEntry item in od)
{
    if (item.Value is string[])
    {
        foreach (string str in (string[])item.Value)
        {
            Console.WriteLine("A string item: " + str);
        }
    }
}