私は以下のコードをc#4.0に用意しています。リスト<Object> Linqを使用して最初のオブジェクトを取得する方法
//Dictionary object with Key as string and Value as List of Component type object
Dictionary<String, List<Component>> dic = new Dictionary<String, List<Component>>();
//Here I am trying to do the loping for List<Component>
foreach (List<Component> lstComp in dic.Values.ToList())
{
// Below I am trying to get first component from the lstComp object.
// Can we achieve same thing using LINQ?
// Which one will give more performance as well as good object handling?
Component depCountry = lstComp[0].ComponentValue("Dep");
}
http://stackoverflow.com/questions/8886796/linq-firstordefault – Satpal
この条件コンポーネントdepCountry = lstComp [0] .ComponentValue( "発")をチェックする方法。まず、lstComp [0]コンポーネントからComponentオブジェクトを取得する方法が簡単なので、コンポーネントにはコンポーネントがあります。 –
'ToList()'を 'Values'にドロップする必要はなく、余分なオブジェクトの作成と全体の値のコレクション。 –