Linq-conversions
提供:Dev Guides
LINQでの変換
演算子は入力オブジェクトのタイプを変更し、さまざまなアプリケーションで使用されます。
Operator | Description | C# Query Expression Syntax | VB Query Expression Syntax |
---|---|---|---|
AsEnumerable | Returns the input typed as IEnumerable<T> | Not Applicable | Not Applicable |
AsQueryable | A (generic) IEnumerable is converted to a (generic) IQueryable | Not Applicable | Not Applicable |
Cast | Performs casting of elements of a collection to a specified type | Use an explicitly typed range variable. Eg:from string str in words | From … As … |
OfType | Filters values on basis of their , depending on their capability to be cast to a particular type | Not Applicable | Not Applicable |
ToArray | Forces query execution and does conversion of a collection to an array | Not Applicable | Not Applicable |
ToDictionary | On basis of a key selector function set elements into a Dictionary<TKey, TValue> and forces execution of a LINQ query | Not Applicable | Not Applicable |
ToList | Forces execution of a query by converting a collection to a List<T> | Not Applicable | Not Applicable |
ToLookup | Forces execution of a query and put elements into a Lookup<TKey, TElement> on basis of a key selector function | Not Applicable | Not Applicable |
キャストの例-クエリ式
C#
VB
C#またはVBの上記のコードがコンパイルされて実行されると、次の結果が生成されます-