Sponsored Ad

Wednesday, October 14, 2009

C# Map

There are a lot of cases where I need to define in code some sort of a map that I would later want to modify. This is usually as simple as mapping a changeless account to be acclimated in the code. This about mapping from System.Type to SqlType, for instance.

typeToSqlType = {

       System.Int32 : System.Data.SqlTypes.SqlInt32

       System.Int64 : System.Data.SqlTypes.SqlInt64

}

 

I am application those types of lists all over the place. In C#, you are affected to use a hashtable or a concordance and manually actualize it. Well, I gave it some though, and it looks like C# does support this syntax, although it is pretty aweful.

 

Type[][] typesToSqlType =

      {

        new Type[]{typeof(System.Int32), typeof(System.Data.SqlTypes.SqlInt32)},

        new Type[]{typeof(System.Int32), typeof(System.Data.SqlTypes.SqlInt32)}

      };

0 comments:

Post a Comment

Sponsored Ad

Website Update

Followers