I would like to build a table data structure in memory with 4 columns so that I can search for values based on any combination of columns (e.g. using linq). Is there a built-in data type for this, or should I create it myself (obviously, I can't)?
If you have something specific, I would declare a type with 4 properties with suitable names and types, i.e.
public class SomethingSuitable { public int Foo {get;set;} public string Bar {get;set;} public DateTime Blap {get;set;} public float Blip {get;set;} }
and if necessary use any list / array / dictionary, etc. or simply
data.Single(x => x.Bar == "abc");
and etc.
Mark the DataTable class.
.Net Framework 4.0, Tuple!
:
# 4.0
, , , - List<Tuple<T1,T2,T3,T4>>
List<Tuple<T1,T2,T3,T4>>
. DataTable
DataTable . .: http://download.microsoft.com/download/5/8/6/5868081c-68aa-40de-9a45-a3803d8134b8/linq_over_dataset_for_csharp_developers.doc
var dataStructure = new[] { new { col1 = "something", col2 = "something else", col3 = 12, col4 = true }, new { col1 = "ha", col2 = "ha ha", col3 = 356, col4 = false }, new { col1 = "grrr", col2 = "grr grr", col3 = 213, col4 = true } };
DataTable a List<FourColClass>, . FourColClass .
DataTable
List<FourColClass>
FourColClass