Queryable.Last 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.
Bir dizideki son öğeyi döndürür.
Aşırı Yüklemeler
| Last<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>) |
Belirtilen koşulu karşılayan bir dizinin son öğesini döndürür. |
| Last<TSource>(IQueryable<TSource>) |
Bir dizideki son öğeyi döndürür. |
Last<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>)
- Kaynak:
- Queryable.cs
- Kaynak:
- Queryable.cs
- Kaynak:
- Queryable.cs
Belirtilen koşulu karşılayan bir dizinin son öğesini döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static TSource Last(System::Linq::IQueryable<TSource> ^ source, System::Linq::Expressions::Expression<Func<TSource, bool> ^> ^ predicate);
public static TSource Last<TSource> (this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,bool>> predicate);
static member Last : System.Linq.IQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, bool>> -> 'Source
<Extension()>
Public Function Last(Of TSource) (source As IQueryable(Of TSource), predicate As Expression(Of Func(Of TSource, Boolean))) As TSource
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IQueryable<TSource>
Öğesi IQueryable<T> döndürülecek öğesi.
- predicate
- Expression<Func<TSource,Boolean>>
Bir koşul için her öğeyi test etmek için bir işlev.
Döndürülenler
içinde source tarafından predicatebelirtilen testi geçen son öğe.
Özel durumlar
source veya predicate şeklindedir null.
Örnekler
Aşağıdaki kod örneği, bir koşulu karşılayan bir dizinin son öğesini döndürmek için nasıl kullanılacağını Last<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>) gösterir.
int[] numbers = { 9, 34, 65, 92, 87, 435, 3, 54,
83, 23, 87, 67, 12, 19 };
// Get the last number in the array that is greater than 80.
int last = numbers.AsQueryable().Last(num => num > 80);
Console.WriteLine(last);
/*
This code produces the following output:
87
*/
Dim numbers() As Integer = {9, 34, 65, 92, 87, 435, 3, 54, _
83, 23, 87, 67, 12, 19}
' Get the last number in the array that is greater than 80.
Dim last As Integer = numbers.AsQueryable().Last(Function(num) num > 80)
MsgBox(last)
' This code produces the following output:
' 87
Açıklamalar
Bu yöntem, tür bağımsız değişkeni türlerden Expression<TDelegate> biri olan türünde en az bir parametreye Func<T,TResult> sahiptir. Bu parametreler için bir lambda ifadesi geçirebilirsiniz ve bu ifade bir Expression<TDelegate>olarak derlenir.
yöntemi, Last<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>) kendisini oluşturulan genel bir MethodCallExpression yöntem olarak çağıran Last<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>) bir oluşturur. Ardından parametresinin MethodCallExpressionExecute<TResult>(Expression) özelliği tarafından temsil edilen yöntemine IQueryProviderProvidersource iletir.
Çağrıyı Last<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>) 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ış, tarafından predicatebelirtilen koşulu karşılayan son öğesini source döndürmesidir.
Şunlara uygulanır
Last<TSource>(IQueryable<TSource>)
- Kaynak:
- Queryable.cs
- Kaynak:
- Queryable.cs
- Kaynak:
- Queryable.cs
Bir dizideki son öğeyi döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static TSource Last(System::Linq::IQueryable<TSource> ^ source);
public static TSource Last<TSource> (this System.Linq.IQueryable<TSource> source);
static member Last : System.Linq.IQueryable<'Source> -> 'Source
<Extension()>
Public Function Last(Of TSource) (source As IQueryable(Of TSource)) As TSource
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IQueryable<TSource>
öğesinin IQueryable<T> son öğesini döndürmek için.
Döndürülenler
içindeki son konumdaki sourcedeğer.
Özel durumlar
source, null değeridir.
Kaynak dizisi boş.
Örnekler
Aşağıdaki kod örneği, bir dizinin son öğesini döndürmek için nasıl kullanılacağını Last<TSource>(IQueryable<TSource>) gösterir.
int[] numbers = { 9, 34, 65, 92, 87, 435, 3, 54,
83, 23, 87, 67, 12, 19 };
int last = numbers.AsQueryable().Last();
Console.WriteLine(last);
/*
This code produces the following output:
19
*/
Dim numbers() As Integer = {9, 34, 65, 92, 87, 435, 3, 54, _
83, 23, 87, 67, 12, 19}
Dim last As Integer = numbers.AsQueryable().Last()
MsgBox(last)
' This code produces the following output:
' 19
Açıklamalar
yöntemi, Last<TSource>(IQueryable<TSource>) kendisini oluşturulan genel bir MethodCallExpression yöntem olarak çağıran Last<TSource>(IQueryable<TSource>) bir oluşturur. Ardından parametresinin MethodCallExpressionExecute<TResult>(Expression) özelliği tarafından temsil edilen yöntemine IQueryProviderProvidersource iletir.
Çağrıyı Last<TSource>(IQueryable<TSource>) 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ış, içindeki son öğeyi döndürmesidir source.