I need some data type like List<int , int , int ,string , int >.
Of course I can implement , but is there something built in .net 3.5.
Thanks .
Tuple types are immutable. Data members of System. ValueTuple types are fields.
NET Framework 4.0. A tuple is a data structure that contains a sequence of elements of different data types. It can be used where you want to have a data structure to hold an object with properties, but you don't want to create a separate type for it.
Why should we use Tuples? You may want to use a tuple to represent a set of heterogeneous data and provide an easy way to access that data. You can also take advantage of a tuple to return multiple values from a method or even pass multiple values to a method.
No, there isn't anything in .NET 3.5. But rather than Tuple, have you considered implementing your own simple type which encapsulates the members you need? Usually that ends up giving more readable code than Tuple anyway - especially when you've got quite a lot of members, most of which have the same types.
It's a lot easier to understand:
foo(sale.AdultTickets, sale.ChildTickets, ...);
than
foo(sale.Item1, sale.Item2, ...);
It's a little bit more work, but it needn't be much more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With