Archive for the ‘Uncategorized’ Category

Posted by OmegaMan at October 15, 2007

Category: Uncategorized

Dictionary<string, string> ColumnValuesHash = new Dictionary<string,  string>();

// ... load with values...
foreach (KeyValuePair<string, string>  entry in ColumnValuesHash)
   Console.WriteLine("{0}: {1}", entry.Key,  entry.Value);


Posted by OmegaMan at August 23, 2007

Category: Uncategorized


In C# one of the most useful constructs is the ability to access data in a class via an indexer. Example is something like this:

MyClass ab() = new MyClass();

string myValue = ab[2];

This example will show you how to use and define an accessor for a class which takes a specific enum. In the example we will the access data within the class with another accessor. In the example, see the static method Usage() on the class for the how to run the example.

public class ShowConcepts
 public enum Operation

 private Dictionary<Operation, List<string>> _myData = new Dictionary<Operation,List<string>>();

 // Index the data here
 public List<string> this[Operation op]
           return _myData[op];

           _myData.Add(op, value);


 public static void Usage()

   List<string> temp = new List<string>();

   ShowConcepts sc = new ShowConcepts();

   sc[Operation.TargetA] = temp;

   temp = new List<string>();

   sc[Operation.TargetB] = temp;

   // Prints Jabberwocky
   Console.WriteLine(sc[Operation.TargetA][0] + sc[Operation.TargetB][0]);


  • Line 03: This will be the basis of each list which we will deal with in this enum. This is a small example, but one can obviously add more. This will be the key to access internal data in the hashtable/dictionary.
  • Line 09: Here is where we hold all the outside user generated string lists, each with the unique Operation enum.
  • Line 13: Process the target list either by setting it or getting it.
  • Line 28: This static method simply demonstrates how to use this class; for this article only.
  • Line 31: Create our first list.
  • Line 34: Create our list manager to hold the lists.
  • Line 36: Send the first list into the manager.
  • Line 41: Send in the second list.
  • Line 44: Access the strings via the multiple indexers.
  • Recent Comments

    Thanks for this simple yet delightful code....
    Hey guys I'm having the same problem as Netanel KL { “Error HRESUL...
    Soluciono el problema con el primero (First step solved it for me)....
    Thank you! I was looking for this. You save my day!...
    Thank you! This was a big help. My requirement was a little differen...
    Thanks, after a small path adjustment it worked for Visual Studio 2015...
    Good call!...
    Thank you .. this helped...
    How about when you have a long string with no space? I tried it and it...
    Thank you, I ran into this same issues with Visual Studio 2015 after i...