In-memory data structure

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)?

+5
source share
8 answers

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.

+5
source

Mark the DataTable class.

+4
source

.Net Framework 4.0, Tuple!

:

# 4.0

+3

, , , - List<Tuple<T1,T2,T3,T4>>

+3
+2

:

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 }
};
+1

DataTable a List<FourColClass>, . FourColClass .

+1

All Articles