Queryable.ElementAt Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| ElementAt<TSource>(IQueryable<TSource>, Index) |
Bir dizideki belirtilen dizindeki öğesini döndürür. |
| ElementAt<TSource>(IQueryable<TSource>, Int32) |
Bir dizideki belirtilen dizindeki öğesini döndürür. |
ElementAt<TSource>(IQueryable<TSource>, Index)
- Kaynak:
- Queryable.cs
- Kaynak:
- Queryable.cs
- Kaynak:
- Queryable.cs
- Kaynak:
- Queryable.cs
- Kaynak:
- Queryable.cs
Bir dizideki belirtilen dizindeki öğesini döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static TSource ElementAt(System::Linq::IQueryable<TSource> ^ source, Index index);
public static TSource ElementAt<TSource>(this System.Linq.IQueryable<TSource> source, Index index);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")]
public static TSource ElementAt<TSource>(this System.Linq.IQueryable<TSource> source, Index index);
static member ElementAt : System.Linq.IQueryable<'Source> * Index -> 'Source
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")>]
static member ElementAt : System.Linq.IQueryable<'Source> * Index -> 'Source
<Extension()>
Public Function ElementAt(Of TSource) (source As IQueryable(Of TSource), index As Index) As TSource
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IQueryable<TSource>
öğesi IQueryable<T> döndürülecek.
- index
- Index
Başlangıçtan veya sonundan alınan öğenin dizini.
Döndürülenler
Dizide belirtilen konumdaki source öğesi.
- Öznitelikler
Özel durumlar
source, null'e eşittir.
index dizinin sınırlarının source dışındadır.
Şunlara uygulanır
ElementAt<TSource>(IQueryable<TSource>, Int32)
- Kaynak:
- Queryable.cs
- Kaynak:
- Queryable.cs
- Kaynak:
- Queryable.cs
- Kaynak:
- Queryable.cs
- Kaynak:
- Queryable.cs
Bir dizideki belirtilen dizindeki öğesini döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static TSource ElementAt(System::Linq::IQueryable<TSource> ^ source, int index);
public static TSource ElementAt<TSource>(this System.Linq.IQueryable<TSource> source, int index);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")]
public static TSource ElementAt<TSource>(this System.Linq.IQueryable<TSource> source, int index);
static member ElementAt : System.Linq.IQueryable<'Source> * int -> 'Source
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")>]
static member ElementAt : System.Linq.IQueryable<'Source> * int -> 'Source
<Extension()>
Public Function ElementAt(Of TSource) (source As IQueryable(Of TSource), index As Integer) As TSource
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IQueryable<TSource>
öğesi IQueryable<T> döndürülecek.
- index
- Int32
Alınacak öğenin sıfır tabanlı dizini.
Döndürülenler
öğesinde belirtilen konumdadır source.
- Öznitelikler
Özel durumlar
source, null'e eşittir.
index, sıfırdan küçüktür.
Örnekler
Aşağıdaki kod örneği, bir dizideki belirli bir konumdaki bir öğeyi döndürmek için nasıl kullanılacağını ElementAt<TSource>(IQueryable<TSource>, Int32) gösterir.
string[] names = { "Hartono, Tommy", "Adams, Terry",
"Andersen, Henriette Thaulow",
"Hedlund, Magnus", "Ito, Shu" };
Random random = new Random(DateTime.Now.Millisecond);
string name =
names.AsQueryable().ElementAt(random.Next(0, names.Length));
Console.WriteLine("The name chosen at random is '{0}'.", name);
/*
This code produces the following sample output.
Yours may be different due to the use of Random.
The name chosen at random is 'Ito, Shu'.
*/
Dim names() As String = {"Hartono, Tommy", "Adams, Terry", _
"Andersen, Henriette Thaulow", _
"Hedlund, Magnus", "Ito, Shu"}
Dim rand As New Random(DateTime.Now.Millisecond)
Dim name As String = _
names.AsQueryable().ElementAt(rand.Next(0, names.Length))
MsgBox(String.Format("The name chosen at random is '{0}'.", name))
' This code produces the following sample output.
' Yours may be different due to the use of Random.
'
' The name chosen at random is 'Ito, Shu'.
Açıklamalar
yöntemi, ElementAt<TSource>(IQueryable<TSource>, Int32) kendisini oluşturulan genel bir MethodCallExpression yöntem olarak çağıran ElementAt<TSource>(IQueryable<TSource>, Int32) bir oluşturur. Ardından parametresinin özelliği tarafından Provider temsil edilen yöntemine sourceIQueryProvider iletirMethodCallExpression.Execute<TResult>(Expression)
Çağrıyı ElementAt<TSource>(IQueryable<TSource>, Int32) temsil eden bir ifade ağacının yürütülmesi sonucunda oluşan sorgu davranışı, parametre türünün uygulanmasına source bağlıdır. Beklenen davranış, öğesini index konumunda döndürmesidir source.