Search code examples
c#genericslistcollectionsstrong-typing

Is this possible using generics? c#


I know I can solve the following problem just by creating a custom class, but can the following be strongly typed as a List(or any other type)?

 var x = new object[] 
        { 
            new object[] { new Image(), new TextBox(), new FileUpload() }, 
            new object[] { new Image(), new TextBox() , new FileUpload()} 
        };

The object types in the code above are just for example.

It's the end of the day and my brain has gone abit soft.

Edit: Tuples?


Solution

  • Yep, generic Tuples would work:

    http://sankarsan.wordpress.com/2009/11/29/tuple-in-c-4-0/

    var myTuples = new List<Tuple<type1, type2, type3>>();