, , ,. 2.0, , - ArrayList.
List<string> myNames = new List<string>();
myNames.Add("kevin");
string[] myNamesTurnedToStringArray = nyMames.ToArray();
, , , , . , , List
public class Widgets : List<Widgets>
{
public Widgets() : base() {}
public Widgets(IEnumerable<Widgets> items) : base(items) {}
public Widget GetWidgetById(int id)
{
return this.Where(w => w.id == id).Single();
}
public string[] GetAllNames()
{
return this.Select(w => w.Name).ToArray();
}
}
Widgets w = new Widgets(dataFromDatabase);
Widget customerWidget = w.GetWidgetById(customerWidgetId);
string[] allNames = w.GetAllNames();
OOPy .