Enumerable.Max 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 değer dizisindeki en büyük değeri döndürür.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| Max(IEnumerable<Nullable<Int64>>) |
Null değer Int64 dizisindeki en büyük değeri döndürür. |
| Max(IEnumerable<Nullable<Int32>>) |
Null değer Int32 dizisindeki en büyük değeri döndürür. |
| Max(IEnumerable<Nullable<Double>>) |
Null değer Double dizisindeki en büyük değeri döndürür. |
| Max(IEnumerable<Nullable<Decimal>>) |
Null değer Decimal dizisindeki en büyük değeri döndürür. |
| Max(IEnumerable<Double>) |
Bir değer dizisindeki Double en büyük değeri döndürür. |
| Max(IEnumerable<Int32>) |
Bir değer dizisindeki Int32 en büyük değeri döndürür. |
| Max(IEnumerable<Decimal>) |
Bir değer dizisindeki Decimal en büyük değeri döndürür. |
| Max(IEnumerable<Nullable<Single>>) |
Null değer Single dizisindeki en büyük değeri döndürür. |
| Max(IEnumerable<Int64>) |
Bir değer dizisindeki Int64 en büyük değeri döndürür. |
| Max(IEnumerable<Single>) |
Bir değer dizisindeki Single en büyük değeri döndürür. |
| Max<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>) |
Genel bir dizinin her öğesinde bir dönüştürme işlevi çağırır ve sonuçta elde edilen en yüksek değeri döndürür. |
| Max<TSource>(IEnumerable<TSource>, IComparer<TSource>) |
Genel bir dizideki en büyük değeri döndürür. |
| Max<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>) |
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve en büyük Decimal değeri döndürür. |
| Max<TSource>(IEnumerable<TSource>, Func<TSource,Double>) |
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve en büyük Double değeri döndürür. |
| Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) |
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve en büyük Int32 değeri döndürür. |
| Max<TSource>(IEnumerable<TSource>, Func<TSource,Int64>) |
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve en büyük Int64 değeri döndürür. |
| Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>) |
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve null atanabilir Decimal maksimum değeri döndürür. |
| Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>) |
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve null atanabilir Double maksimum değeri döndürür. |
| Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>) |
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve null atanabilir Int32 maksimum değeri döndürür. |
| Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>) |
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve null atanabilir Int64 maksimum değeri döndürür. |
| Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>) |
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve null atanabilir Single maksimum değeri döndürür. |
| Max<TSource>(IEnumerable<TSource>) |
Genel bir dizideki en büyük değeri döndürür. |
| Max<TSource>(IEnumerable<TSource>, Func<TSource,Single>) |
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve en büyük Single değeri döndürür. |
Max(IEnumerable<Nullable<Int64>>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Null değer Int64 dizisindeki en büyük değeri döndürür.
public:
[System::Runtime::CompilerServices::Extension]
static Nullable<long> Max(System::Collections::Generic::IEnumerable<Nullable<long>> ^ source);
public static long? Max(this System.Collections.Generic.IEnumerable<long?> source);
static member Max : seq<Nullable<int64>> -> Nullable<int64>
<Extension()>
Public Function Max (source As IEnumerable(Of Nullable(Of Long))) As Nullable(Of Long)
Parametreler
- source
- IEnumerable<Nullable<Int64>>
En büyük değerini belirlemek için null atanabilir Int64 değerler dizisi.
Döndürülenler
C# dilinde Nullable<Int64> veya Visual Basic'da Nullable(Of Int64) türünde, dizideki en büyük değere karşılık gelen bir değer.
Özel durumlar
source, null'e eşittir.
Açıklamalar
yöntemi, Max(IEnumerable<Nullable<Int64>>) değerlerini karşılaştırmak için uygulamasını Int64 kullanırIComparable<T>.
Kaynak dizisi boşsa veya yalnızca olan değerleri nulliçeriyorsa, bu işlev döndürür null.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max(IEnumerable<Nullable<Int32>>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Null değer Int32 dizisindeki en büyük değeri döndürür.
public:
[System::Runtime::CompilerServices::Extension]
static Nullable<int> Max(System::Collections::Generic::IEnumerable<Nullable<int>> ^ source);
public static int? Max(this System.Collections.Generic.IEnumerable<int?> source);
static member Max : seq<Nullable<int>> -> Nullable<int>
<Extension()>
Public Function Max (source As IEnumerable(Of Nullable(Of Integer))) As Nullable(Of Integer)
Parametreler
- source
- IEnumerable<Nullable<Int32>>
En büyük değerini belirlemek için null atanabilir Int32 değerler dizisi.
Döndürülenler
C# dilinde Nullable<Int32> veya Visual Basic'da Nullable(Of Int32) türünde, dizideki en büyük değere karşılık gelen bir değer.
Özel durumlar
source, null'e eşittir.
Açıklamalar
yöntemi, Max(IEnumerable<Nullable<Int32>>) değerlerini karşılaştırmak için uygulamasını Int32 kullanırIComparable<T>.
Kaynak dizisi boşsa veya yalnızca olan değerleri nulliçeriyorsa, bu işlev döndürür null.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max(IEnumerable<Nullable<Double>>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Null değer Double dizisindeki en büyük değeri döndürür.
public:
[System::Runtime::CompilerServices::Extension]
static Nullable<double> Max(System::Collections::Generic::IEnumerable<Nullable<double>> ^ source);
public static double? Max(this System.Collections.Generic.IEnumerable<double?> source);
static member Max : seq<Nullable<double>> -> Nullable<double>
<Extension()>
Public Function Max (source As IEnumerable(Of Nullable(Of Double))) As Nullable(Of Double)
Parametreler
- source
- IEnumerable<Nullable<Double>>
En büyük değerini belirlemek için null atanabilir Double değerler dizisi.
Döndürülenler
C# dilinde Nullable<Double> veya Visual Basic'da Nullable(Of Double) türünde, dizideki en büyük değere karşılık gelen bir değer.
Özel durumlar
source, null'e eşittir.
Örnekler
Aşağıdaki kod örneği, bir dizideki en büyük değeri belirlemek için nasıl kullanılacağını Max(IEnumerable<Nullable<Double>>) gösterir.
double?[] doubles = { null, 1.5E+104, 9E+103, -2E+103 };
double? max = doubles.Max();
Console.WriteLine("The largest number is {0}.", max);
/*
This code produces the following output:
The largest number is 1.5E+104.
*/
' Create an array of Nullable Double values.
Dim doubles() As Nullable(Of Double) =
{Nothing, 1.5E+104, 9.0E+103, -2.0E+103}
' Determine the maximum value in the array.
Dim max As Nullable(Of Double) = doubles.Max()
' Display the result.
Console.WriteLine($"The largest number is {max}")
' This code produces the following output:
'
' The largest number is 1.5E+104
Açıklamalar
yöntemi, Max(IEnumerable<Nullable<Double>>) değerlerini karşılaştırmak için uygulamasını Double kullanırIComparable<T>.
Kaynak dizisi boşsa veya yalnızca olan değerleri nulliçeriyorsa, bu işlev döndürür null.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max(IEnumerable<Nullable<Decimal>>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Null değer Decimal dizisindeki en büyük değeri döndürür.
public:
[System::Runtime::CompilerServices::Extension]
static Nullable<System::Decimal> Max(System::Collections::Generic::IEnumerable<Nullable<System::Decimal>> ^ source);
public static decimal? Max(this System.Collections.Generic.IEnumerable<decimal?> source);
static member Max : seq<Nullable<decimal>> -> Nullable<decimal>
<Extension()>
Public Function Max (source As IEnumerable(Of Nullable(Of Decimal))) As Nullable(Of Decimal)
Parametreler
- source
- IEnumerable<Nullable<Decimal>>
En büyük değerini belirlemek için null atanabilir Decimal değerler dizisi.
Döndürülenler
C# dilinde Nullable<Decimal> veya Visual Basic'da Nullable(Of Decimal) türünde, dizideki en büyük değere karşılık gelen bir değer.
Özel durumlar
source, null'e eşittir.
Açıklamalar
yöntemi, Max(IEnumerable<Nullable<Decimal>>) değerlerini karşılaştırmak için uygulamasını Decimal kullanırIComparable<T>.
Kaynak dizisi boşsa veya yalnızca olan değerleri nulliçeriyorsa, bu işlev döndürür null.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max(IEnumerable<Double>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Bir değer dizisindeki Double en büyük değeri döndürür.
public:
[System::Runtime::CompilerServices::Extension]
static double Max(System::Collections::Generic::IEnumerable<double> ^ source);
public static double Max(this System.Collections.Generic.IEnumerable<double> source);
static member Max : seq<double> -> double
<Extension()>
Public Function Max (source As IEnumerable(Of Double)) As Double
Parametreler
- source
- IEnumerable<Double>
En büyük değerini belirlemek için bir değer dizisi Double .
Döndürülenler
Dizideki en büyük değer.
Özel durumlar
source, null'e eşittir.
source öğe içermiyor.
Açıklamalar
yöntemi, Max(IEnumerable<Double>) değerlerini karşılaştırmak için uygulamasını Double kullanırIComparable<T>.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max(IEnumerable<Int32>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Bir değer dizisindeki Int32 en büyük değeri döndürür.
public:
[System::Runtime::CompilerServices::Extension]
static int Max(System::Collections::Generic::IEnumerable<int> ^ source);
public static int Max(this System.Collections.Generic.IEnumerable<int> source);
static member Max : seq<int> -> int
<Extension()>
Public Function Max (source As IEnumerable(Of Integer)) As Integer
Parametreler
- source
- IEnumerable<Int32>
En büyük değerini belirlemek için bir değer dizisi Int32 .
Döndürülenler
Dizideki en büyük değer.
Özel durumlar
source, null'e eşittir.
source öğe içermiyor.
Açıklamalar
yöntemi, Max(IEnumerable<Int32>) değerlerini karşılaştırmak için uygulamasını Int32 kullanırIComparable<T>.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max(IEnumerable<Decimal>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Bir değer dizisindeki Decimal en büyük değeri döndürür.
public:
[System::Runtime::CompilerServices::Extension]
static System::Decimal Max(System::Collections::Generic::IEnumerable<System::Decimal> ^ source);
public static decimal Max(this System.Collections.Generic.IEnumerable<decimal> source);
static member Max : seq<decimal> -> decimal
<Extension()>
Public Function Max (source As IEnumerable(Of Decimal)) As Decimal
Parametreler
- source
- IEnumerable<Decimal>
En büyük değerini belirlemek için bir değer dizisi Decimal .
Döndürülenler
Dizideki en büyük değer.
Özel durumlar
source, null'e eşittir.
source öğe içermiyor.
Açıklamalar
yöntemi, Max(IEnumerable<Decimal>) değerlerini karşılaştırmak için uygulamasını Decimal kullanırIComparable<T>.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max(IEnumerable<Nullable<Single>>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Null değer Single dizisindeki en büyük değeri döndürür.
public:
[System::Runtime::CompilerServices::Extension]
static Nullable<float> Max(System::Collections::Generic::IEnumerable<Nullable<float>> ^ source);
public static float? Max(this System.Collections.Generic.IEnumerable<float?> source);
static member Max : seq<Nullable<single>> -> Nullable<single>
<Extension()>
Public Function Max (source As IEnumerable(Of Nullable(Of Single))) As Nullable(Of Single)
Parametreler
- source
- IEnumerable<Nullable<Single>>
En büyük değerini belirlemek için null atanabilir Single değerler dizisi.
Döndürülenler
C# dilinde Nullable<Single> veya Visual Basic'da Nullable(Of Single) türünde, dizideki en büyük değere karşılık gelen bir değer.
Özel durumlar
source, null'e eşittir.
Açıklamalar
yöntemi, Max(IEnumerable<Nullable<Single>>) değerlerini karşılaştırmak için uygulamasını Single kullanırIComparable<T>.
Kaynak dizisi boşsa veya yalnızca olan değerleri nulliçeriyorsa, bu işlev döndürür null.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max(IEnumerable<Int64>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Bir değer dizisindeki Int64 en büyük değeri döndürür.
public:
[System::Runtime::CompilerServices::Extension]
static long Max(System::Collections::Generic::IEnumerable<long> ^ source);
public static long Max(this System.Collections.Generic.IEnumerable<long> source);
static member Max : seq<int64> -> int64
<Extension()>
Public Function Max (source As IEnumerable(Of Long)) As Long
Parametreler
- source
- IEnumerable<Int64>
En büyük değerini belirlemek için bir değer dizisi Int64 .
Döndürülenler
Dizideki en büyük değer.
Özel durumlar
source, null'e eşittir.
source öğe içermiyor.
Örnekler
Aşağıdaki kod örneği, bir dizideki en büyük değeri belirlemek için nasıl kullanılacağını Max(IEnumerable<Int64>) gösterir.
List<long> longs = new List<long> { 4294967296L, 466855135L, 81125L };
long max = longs.Max();
Console.WriteLine("The largest number is {0}.", max);
/*
This code produces the following output:
The largest number is 4294967296.
*/
' Create a list of Long values.
Dim longs As New List(Of Long)(New Long() _
{4294967296L, 466855135L, 81125L})
' Get the maximum value in the list.
Dim max As Long = longs.Max()
' Display the result.
Console.WriteLine($"The largest number is {max}")
' This code produces the following output:
'
' The largest number is 4294967296
Açıklamalar
yöntemi, Max(IEnumerable<Int64>) değerlerini karşılaştırmak için uygulamasını Int64 kullanırIComparable<T>.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max(IEnumerable<Single>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Bir değer dizisindeki Single en büyük değeri döndürür.
public:
[System::Runtime::CompilerServices::Extension]
static float Max(System::Collections::Generic::IEnumerable<float> ^ source);
public static float Max(this System.Collections.Generic.IEnumerable<float> source);
static member Max : seq<single> -> single
<Extension()>
Public Function Max (source As IEnumerable(Of Single)) As Single
Parametreler
- source
- IEnumerable<Single>
En büyük değerini belirlemek için bir değer dizisi Single .
Döndürülenler
Dizideki en büyük değer.
Özel durumlar
source, null'e eşittir.
source öğe içermiyor.
Açıklamalar
yöntemi, Max(IEnumerable<Single>) değerlerini karşılaştırmak için uygulamasını Single kullanırIComparable<T>.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Genel bir dizinin her öğesinde bir dönüştürme işlevi çağırır ve sonuçta elde edilen en yüksek değeri döndürür.
public:
generic <typename TSource, typename TResult>
[System::Runtime::CompilerServices::Extension]
static TResult Max(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, TResult> ^ selector);
public static TResult Max<TSource,TResult>(this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,TResult> selector);
public static TResult? Max<TSource,TResult>(this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,TResult> selector);
static member Max : seq<'Source> * Func<'Source, 'Result> -> 'Result
<Extension()>
Public Function Max(Of TSource, TResult) (source As IEnumerable(Of TSource), selector As Func(Of TSource, TResult)) As TResult
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
- TResult
tarafından selectordöndürülen değerin türü.
Parametreler
- source
- IEnumerable<TSource>
En büyük değerini belirlemek için bir değer dizisi.
- selector
- Func<TSource,TResult>
Her öğeye uygulanacak bir dönüştürme işlevi.
Döndürülenler
Dizideki en büyük değer.
Özel durumlar
source veya selector şeklindedir null.
Örnekler
Aşağıdaki kod örneği, yansıtılan değerler dizisindeki en yüksek değeri belirlemek için nasıl kullanılacağını Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) gösterir.
Note
Bu kod örneği, yöntemin bu makalede açıklanan aşırı yüklemeden farklı bir aşırı yüklemesini kullanır. Örneği bu makalede açıklanan aşırı yüklemeye genişletmek için işlevin gövdesini selector değiştirin.
class Pet
{
public string Name { get; set; }
public int Age { get; set; }
}
public static void MaxEx4()
{
Pet[] pets = { new Pet { Name="Barley", Age=8 },
new Pet { Name="Boots", Age=4 },
new Pet { Name="Whiskers", Age=1 } };
int max = pets.Max(pet => pet.Age + pet.Name.Length);
Console.WriteLine(
"The maximum pet age plus name length is {0}.",
max);
}
/*
This code produces the following output:
The maximum pet age plus name length is 14.
*/
Structure Pet
Public Name As String
Public Age As Integer
End Structure
Sub MaxEx4()
' Create an array of Pet objects.
Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
New Pet With {.Name = "Boots", .Age = 4},
New Pet With {.Name = "Whiskers", .Age = 1}}
' Determine the "maximum" pet by passing a
' lambda expression to Max() that sums the pet's age
' and name length.
Dim max As Integer = pets.Max(Function(pet) _
pet.Age + pet.Name.Length)
' Display the result.
Console.WriteLine($"The maximum pet age plus name length is {max}")
End Sub
' This code produces the following output:
'
' The maximum pet age plus name length is 14
Açıklamalar
türü TResult uygularsa IComparable<T>, bu yöntem değerleri karşılaştırmak için bu uygulamayı kullanır. Aksi takdirde, tür TResult uygularsa IComparable, bu uygulama değerleri karşılaştırmak için kullanılır.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max<TSource>(IEnumerable<TSource>, IComparer<TSource>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Genel bir dizideki en büyük değeri döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static TSource Max(System::Collections::Generic::IEnumerable<TSource> ^ source, System::Collections::Generic::IComparer<TSource> ^ comparer);
public static TSource? Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Collections.Generic.IComparer<TSource>? comparer);
static member Max : seq<'Source> * System.Collections.Generic.IComparer<'Source> -> 'Source
<Extension()>
Public Function Max(Of TSource) (source As IEnumerable(Of TSource), comparer As IComparer(Of TSource)) As TSource
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IEnumerable<TSource>
En büyük değerini belirlemek için bir değer dizisi.
- comparer
- IComparer<TSource>
IComparer<T> değerleri karşılaştırmak için.
Döndürülenler
Dizideki en büyük değer.
Özel durumlar
source, null'e eşittir.
içindeki source hiçbir nesne veya IComparable arabirimini IComparable<T> uygulamaz.
Açıklamalar
türü TSource uygularsa IComparable<T>Max<TSource>(IEnumerable<TSource>) yöntemi, değerleri karşılaştırmak için bu uygulamayı kullanır. Aksi takdirde, tür TSource uygularsa IComparable, bu uygulama değerleri karşılaştırmak için kullanılır.
Bir başvuru türüyse ve kaynak dizisi boşsa TSource veya yalnızca olan nulldeğerleri içeriyorsa, bu yöntem döndürür null.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Şunlara uygulanır
Max<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve en büyük Decimal değeri döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static System::Decimal Max(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, System::Decimal> ^ selector);
public static decimal Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,decimal> selector);
static member Max : seq<'Source> * Func<'Source, decimal> -> decimal
<Extension()>
Public Function Max(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Decimal)) As Decimal
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IEnumerable<TSource>
En büyük değerini belirlemek için bir değer dizisi.
Döndürülenler
Dizideki en büyük değer.
Özel durumlar
source veya selector şeklindedir null.
source öğe içermiyor.
Örnekler
Aşağıdaki kod örneği, yansıtılan değerler dizisindeki en yüksek değeri belirlemek için nasıl kullanılacağını Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) gösterir.
Note
Bu kod örneği, yöntemin bu makalede açıklanan aşırı yüklemeden farklı bir aşırı yüklemesini kullanır. Örneği bu makalede açıklanan aşırı yüklemeye genişletmek için işlevin gövdesini selector değiştirin.
class Pet
{
public string Name { get; set; }
public int Age { get; set; }
}
public static void MaxEx4()
{
Pet[] pets = { new Pet { Name="Barley", Age=8 },
new Pet { Name="Boots", Age=4 },
new Pet { Name="Whiskers", Age=1 } };
int max = pets.Max(pet => pet.Age + pet.Name.Length);
Console.WriteLine(
"The maximum pet age plus name length is {0}.",
max);
}
/*
This code produces the following output:
The maximum pet age plus name length is 14.
*/
Structure Pet
Public Name As String
Public Age As Integer
End Structure
Sub MaxEx4()
' Create an array of Pet objects.
Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
New Pet With {.Name = "Boots", .Age = 4},
New Pet With {.Name = "Whiskers", .Age = 1}}
' Determine the "maximum" pet by passing a
' lambda expression to Max() that sums the pet's age
' and name length.
Dim max As Integer = pets.Max(Function(pet) _
pet.Age + pet.Name.Length)
' Display the result.
Console.WriteLine($"The maximum pet age plus name length is {max}")
End Sub
' This code produces the following output:
'
' The maximum pet age plus name length is 14
Açıklamalar
yöntemi, Max<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>) değerlerini karşılaştırmak için uygulamasını Decimal kullanırIComparable<T>.
Bu yöntemi, selectorüyelerini sayısal bir türe ( özellikle source) projeleyen bir işlev sağlarsanız, rastgele değerler dizisine Decimal uygulayabilirsiniz.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max<TSource>(IEnumerable<TSource>, Func<TSource,Double>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve en büyük Double değeri döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static double Max(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, double> ^ selector);
public static double Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,double> selector);
static member Max : seq<'Source> * Func<'Source, double> -> double
<Extension()>
Public Function Max(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Double)) As Double
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IEnumerable<TSource>
En büyük değerini belirlemek için bir değer dizisi.
Döndürülenler
Dizideki en büyük değer.
Özel durumlar
source veya selector şeklindedir null.
source öğe içermiyor.
Örnekler
Aşağıdaki kod örneği, yansıtılan değerler dizisindeki en yüksek değeri belirlemek için nasıl kullanılacağını Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) gösterir.
Note
Bu kod örneği, yöntemin bu makalede açıklanan aşırı yüklemeden farklı bir aşırı yüklemesini kullanır. Örneği bu makalede açıklanan aşırı yüklemeye genişletmek için işlevin gövdesini selector değiştirin.
class Pet
{
public string Name { get; set; }
public int Age { get; set; }
}
public static void MaxEx4()
{
Pet[] pets = { new Pet { Name="Barley", Age=8 },
new Pet { Name="Boots", Age=4 },
new Pet { Name="Whiskers", Age=1 } };
int max = pets.Max(pet => pet.Age + pet.Name.Length);
Console.WriteLine(
"The maximum pet age plus name length is {0}.",
max);
}
/*
This code produces the following output:
The maximum pet age plus name length is 14.
*/
Structure Pet
Public Name As String
Public Age As Integer
End Structure
Sub MaxEx4()
' Create an array of Pet objects.
Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
New Pet With {.Name = "Boots", .Age = 4},
New Pet With {.Name = "Whiskers", .Age = 1}}
' Determine the "maximum" pet by passing a
' lambda expression to Max() that sums the pet's age
' and name length.
Dim max As Integer = pets.Max(Function(pet) _
pet.Age + pet.Name.Length)
' Display the result.
Console.WriteLine($"The maximum pet age plus name length is {max}")
End Sub
' This code produces the following output:
'
' The maximum pet age plus name length is 14
Açıklamalar
yöntemi, Max<TSource>(IEnumerable<TSource>, Func<TSource,Double>) değerlerini karşılaştırmak için uygulamasını Double kullanırIComparable<T>.
Bu yöntemi, selectorüyelerini sayısal bir türe ( özellikle source) projeleyen bir işlev sağlarsanız, rastgele değerler dizisine Double uygulayabilirsiniz.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve en büyük Int32 değeri döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static int Max(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, int> ^ selector);
public static int Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,int> selector);
static member Max : seq<'Source> * Func<'Source, int> -> int
<Extension()>
Public Function Max(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Integer)) As Integer
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IEnumerable<TSource>
En büyük değerini belirlemek için bir değer dizisi.
Döndürülenler
Dizideki en büyük değer.
Özel durumlar
source veya selector şeklindedir null.
source öğe içermiyor.
Örnekler
Aşağıdaki kod örneği, yansıtılan değerler dizisindeki en yüksek değeri belirlemek için nasıl kullanılacağını Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) gösterir.
class Pet
{
public string Name { get; set; }
public int Age { get; set; }
}
public static void MaxEx4()
{
Pet[] pets = { new Pet { Name="Barley", Age=8 },
new Pet { Name="Boots", Age=4 },
new Pet { Name="Whiskers", Age=1 } };
int max = pets.Max(pet => pet.Age + pet.Name.Length);
Console.WriteLine(
"The maximum pet age plus name length is {0}.",
max);
}
/*
This code produces the following output:
The maximum pet age plus name length is 14.
*/
Structure Pet
Public Name As String
Public Age As Integer
End Structure
Sub MaxEx4()
' Create an array of Pet objects.
Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
New Pet With {.Name = "Boots", .Age = 4},
New Pet With {.Name = "Whiskers", .Age = 1}}
' Determine the "maximum" pet by passing a
' lambda expression to Max() that sums the pet's age
' and name length.
Dim max As Integer = pets.Max(Function(pet) _
pet.Age + pet.Name.Length)
' Display the result.
Console.WriteLine($"The maximum pet age plus name length is {max}")
End Sub
' This code produces the following output:
'
' The maximum pet age plus name length is 14
Açıklamalar
yöntemi, Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) değerlerini karşılaştırmak için uygulamasını Int32 kullanırIComparable<T>.
Bu yöntemi, selectorüyelerini sayısal bir türe ( özellikle source) projeleyen bir işlev sağlarsanız, rastgele değerler dizisine Int32 uygulayabilirsiniz.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve en büyük Int64 değeri döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static long Max(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, long> ^ selector);
public static long Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,long> selector);
static member Max : seq<'Source> * Func<'Source, int64> -> int64
<Extension()>
Public Function Max(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Long)) As Long
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IEnumerable<TSource>
En büyük değerini belirlemek için bir değer dizisi.
Döndürülenler
Dizideki en büyük değer.
Özel durumlar
source veya selector şeklindedir null.
source öğe içermiyor.
Örnekler
Aşağıdaki kod örneği, yansıtılan değerler dizisindeki en yüksek değeri belirlemek için nasıl kullanılacağını Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) gösterir.
Note
Bu kod örneği, yöntemin bu makalede açıklanan aşırı yüklemeden farklı bir aşırı yüklemesini kullanır. Örneği bu makalede açıklanan aşırı yüklemeye genişletmek için işlevin gövdesini selector değiştirin.
class Pet
{
public string Name { get; set; }
public int Age { get; set; }
}
public static void MaxEx4()
{
Pet[] pets = { new Pet { Name="Barley", Age=8 },
new Pet { Name="Boots", Age=4 },
new Pet { Name="Whiskers", Age=1 } };
int max = pets.Max(pet => pet.Age + pet.Name.Length);
Console.WriteLine(
"The maximum pet age plus name length is {0}.",
max);
}
/*
This code produces the following output:
The maximum pet age plus name length is 14.
*/
Structure Pet
Public Name As String
Public Age As Integer
End Structure
Sub MaxEx4()
' Create an array of Pet objects.
Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
New Pet With {.Name = "Boots", .Age = 4},
New Pet With {.Name = "Whiskers", .Age = 1}}
' Determine the "maximum" pet by passing a
' lambda expression to Max() that sums the pet's age
' and name length.
Dim max As Integer = pets.Max(Function(pet) _
pet.Age + pet.Name.Length)
' Display the result.
Console.WriteLine($"The maximum pet age plus name length is {max}")
End Sub
' This code produces the following output:
'
' The maximum pet age plus name length is 14
Açıklamalar
yöntemi, Max<TSource>(IEnumerable<TSource>, Func<TSource,Int64>) değerlerini karşılaştırmak için uygulamasını Int64 kullanırIComparable<T>.
Bu yöntemi, selectorüyelerini sayısal bir türe ( özellikle source) projeleyen bir işlev sağlarsanız, rastgele değerler dizisine Int64 uygulayabilirsiniz.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve null atanabilir Decimal maksimum değeri döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static Nullable<System::Decimal> Max(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, Nullable<System::Decimal>> ^ selector);
public static decimal? Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,decimal?> selector);
static member Max : seq<'Source> * Func<'Source, Nullable<decimal>> -> Nullable<decimal>
<Extension()>
Public Function Max(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Nullable(Of Decimal))) As Nullable(Of Decimal)
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IEnumerable<TSource>
En büyük değerini belirlemek için bir değer dizisi.
Döndürülenler
C# dilinde Nullable<Decimal> veya dizideki en büyük değere karşılık gelen Visual Basic Nullable(Of Decimal) türündeki değer.
Özel durumlar
source veya selector şeklindedir null.
Örnekler
Aşağıdaki kod örneği, yansıtılan değerler dizisindeki en yüksek değeri belirlemek için nasıl kullanılacağını Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) gösterir.
Note
Bu kod örneği, yöntemin bu makalede açıklanan aşırı yüklemeden farklı bir aşırı yüklemesini kullanır. Örneği bu makalede açıklanan aşırı yüklemeye genişletmek için işlevin gövdesini selector değiştirin.
class Pet
{
public string Name { get; set; }
public int Age { get; set; }
}
public static void MaxEx4()
{
Pet[] pets = { new Pet { Name="Barley", Age=8 },
new Pet { Name="Boots", Age=4 },
new Pet { Name="Whiskers", Age=1 } };
int max = pets.Max(pet => pet.Age + pet.Name.Length);
Console.WriteLine(
"The maximum pet age plus name length is {0}.",
max);
}
/*
This code produces the following output:
The maximum pet age plus name length is 14.
*/
Structure Pet
Public Name As String
Public Age As Integer
End Structure
Sub MaxEx4()
' Create an array of Pet objects.
Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
New Pet With {.Name = "Boots", .Age = 4},
New Pet With {.Name = "Whiskers", .Age = 1}}
' Determine the "maximum" pet by passing a
' lambda expression to Max() that sums the pet's age
' and name length.
Dim max As Integer = pets.Max(Function(pet) _
pet.Age + pet.Name.Length)
' Display the result.
Console.WriteLine($"The maximum pet age plus name length is {max}")
End Sub
' This code produces the following output:
'
' The maximum pet age plus name length is 14
Açıklamalar
yöntemi, Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>) değerlerini karşılaştırmak için uygulamasını Decimal kullanırIComparable<T>.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve null atanabilir Double maksimum değeri döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static Nullable<double> Max(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, Nullable<double>> ^ selector);
public static double? Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,double?> selector);
static member Max : seq<'Source> * Func<'Source, Nullable<double>> -> Nullable<double>
<Extension()>
Public Function Max(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Nullable(Of Double))) As Nullable(Of Double)
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IEnumerable<TSource>
En büyük değerini belirlemek için bir değer dizisi.
Döndürülenler
C# dilinde Nullable<Double> veya dizideki en büyük değere karşılık gelen Visual Basic Nullable(Of Double) türündeki değer.
Özel durumlar
source veya selector şeklindedir null.
Örnekler
Aşağıdaki kod örneği, yansıtılan değerler dizisindeki en yüksek değeri belirlemek için nasıl kullanılacağını Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) gösterir.
Note
Bu kod örneği, yöntemin bu makalede açıklanan aşırı yüklemeden farklı bir aşırı yüklemesini kullanır. Örneği bu makalede açıklanan aşırı yüklemeye genişletmek için işlevin gövdesini selector değiştirin.
class Pet
{
public string Name { get; set; }
public int Age { get; set; }
}
public static void MaxEx4()
{
Pet[] pets = { new Pet { Name="Barley", Age=8 },
new Pet { Name="Boots", Age=4 },
new Pet { Name="Whiskers", Age=1 } };
int max = pets.Max(pet => pet.Age + pet.Name.Length);
Console.WriteLine(
"The maximum pet age plus name length is {0}.",
max);
}
/*
This code produces the following output:
The maximum pet age plus name length is 14.
*/
Structure Pet
Public Name As String
Public Age As Integer
End Structure
Sub MaxEx4()
' Create an array of Pet objects.
Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
New Pet With {.Name = "Boots", .Age = 4},
New Pet With {.Name = "Whiskers", .Age = 1}}
' Determine the "maximum" pet by passing a
' lambda expression to Max() that sums the pet's age
' and name length.
Dim max As Integer = pets.Max(Function(pet) _
pet.Age + pet.Name.Length)
' Display the result.
Console.WriteLine($"The maximum pet age plus name length is {max}")
End Sub
' This code produces the following output:
'
' The maximum pet age plus name length is 14
Açıklamalar
yöntemi, Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>) değerlerini karşılaştırmak için uygulamasını Double kullanırIComparable<T>.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve null atanabilir Int32 maksimum değeri döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static Nullable<int> Max(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, Nullable<int>> ^ selector);
public static int? Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,int?> selector);
static member Max : seq<'Source> * Func<'Source, Nullable<int>> -> Nullable<int>
<Extension()>
Public Function Max(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Nullable(Of Integer))) As Nullable(Of Integer)
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IEnumerable<TSource>
En büyük değerini belirlemek için bir değer dizisi.
Döndürülenler
C# dilinde Nullable<Int32> veya dizideki en büyük değere karşılık gelen Visual Basic Nullable(Of Int32) türündeki değer.
Özel durumlar
source veya selector şeklindedir null.
Örnekler
Aşağıdaki kod örneği, yansıtılan değerler dizisindeki en yüksek değeri belirlemek için nasıl kullanılacağını Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) gösterir.
Note
Bu kod örneği, yöntemin bu makalede açıklanan aşırı yüklemeden farklı bir aşırı yüklemesini kullanır. Örneği bu makalede açıklanan aşırı yüklemeye genişletmek için işlevin gövdesini selector değiştirin.
class Pet
{
public string Name { get; set; }
public int Age { get; set; }
}
public static void MaxEx4()
{
Pet[] pets = { new Pet { Name="Barley", Age=8 },
new Pet { Name="Boots", Age=4 },
new Pet { Name="Whiskers", Age=1 } };
int max = pets.Max(pet => pet.Age + pet.Name.Length);
Console.WriteLine(
"The maximum pet age plus name length is {0}.",
max);
}
/*
This code produces the following output:
The maximum pet age plus name length is 14.
*/
Structure Pet
Public Name As String
Public Age As Integer
End Structure
Sub MaxEx4()
' Create an array of Pet objects.
Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
New Pet With {.Name = "Boots", .Age = 4},
New Pet With {.Name = "Whiskers", .Age = 1}}
' Determine the "maximum" pet by passing a
' lambda expression to Max() that sums the pet's age
' and name length.
Dim max As Integer = pets.Max(Function(pet) _
pet.Age + pet.Name.Length)
' Display the result.
Console.WriteLine($"The maximum pet age plus name length is {max}")
End Sub
' This code produces the following output:
'
' The maximum pet age plus name length is 14
Açıklamalar
yöntemi, Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>) değerlerini karşılaştırmak için uygulamasını Int32 kullanırIComparable<T>.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve null atanabilir Int64 maksimum değeri döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static Nullable<long> Max(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, Nullable<long>> ^ selector);
public static long? Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,long?> selector);
static member Max : seq<'Source> * Func<'Source, Nullable<int64>> -> Nullable<int64>
<Extension()>
Public Function Max(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Nullable(Of Long))) As Nullable(Of Long)
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IEnumerable<TSource>
En büyük değerini belirlemek için bir değer dizisi.
Döndürülenler
Dizideki en büyük değere karşılık gelen değer.
Özel durumlar
source veya selector şeklindedir null.
Örnekler
Aşağıdaki kod örneği, yansıtılan değerler dizisindeki en yüksek değeri belirlemek için nasıl kullanılacağını Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) gösterir.
Note
Bu kod örneği, yöntemin bu makalede açıklanan aşırı yüklemeden farklı bir aşırı yüklemesini kullanır. Örneği bu makalede açıklanan aşırı yüklemeye genişletmek için işlevin gövdesini selector değiştirin.
class Pet
{
public string Name { get; set; }
public int Age { get; set; }
}
public static void MaxEx4()
{
Pet[] pets = { new Pet { Name="Barley", Age=8 },
new Pet { Name="Boots", Age=4 },
new Pet { Name="Whiskers", Age=1 } };
int max = pets.Max(pet => pet.Age + pet.Name.Length);
Console.WriteLine(
"The maximum pet age plus name length is {0}.",
max);
}
/*
This code produces the following output:
The maximum pet age plus name length is 14.
*/
Structure Pet
Public Name As String
Public Age As Integer
End Structure
Sub MaxEx4()
' Create an array of Pet objects.
Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
New Pet With {.Name = "Boots", .Age = 4},
New Pet With {.Name = "Whiskers", .Age = 1}}
' Determine the "maximum" pet by passing a
' lambda expression to Max() that sums the pet's age
' and name length.
Dim max As Integer = pets.Max(Function(pet) _
pet.Age + pet.Name.Length)
' Display the result.
Console.WriteLine($"The maximum pet age plus name length is {max}")
End Sub
' This code produces the following output:
'
' The maximum pet age plus name length is 14
Açıklamalar
yöntemi, Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>) değerlerini karşılaştırmak için uygulamasını Int64 kullanırIComparable<T>.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve null atanabilir Single maksimum değeri döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static Nullable<float> Max(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, Nullable<float>> ^ selector);
public static float? Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,float?> selector);
static member Max : seq<'Source> * Func<'Source, Nullable<single>> -> Nullable<single>
<Extension()>
Public Function Max(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Nullable(Of Single))) As Nullable(Of Single)
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IEnumerable<TSource>
En büyük değerini belirlemek için bir değer dizisi.
Döndürülenler
Dizideki en büyük değere karşılık gelen değer.
Özel durumlar
source veya selector şeklindedir null.
Örnekler
Aşağıdaki kod örneği, yansıtılan değerler dizisindeki en yüksek değeri belirlemek için nasıl kullanılacağını Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) gösterir.
Note
Bu kod örneği, yöntemin bu makalede açıklanan aşırı yüklemeden farklı bir aşırı yüklemesini kullanır. Örneği bu makalede açıklanan aşırı yüklemeye genişletmek için işlevin gövdesini selector değiştirin.
class Pet
{
public string Name { get; set; }
public int Age { get; set; }
}
public static void MaxEx4()
{
Pet[] pets = { new Pet { Name="Barley", Age=8 },
new Pet { Name="Boots", Age=4 },
new Pet { Name="Whiskers", Age=1 } };
int max = pets.Max(pet => pet.Age + pet.Name.Length);
Console.WriteLine(
"The maximum pet age plus name length is {0}.",
max);
}
/*
This code produces the following output:
The maximum pet age plus name length is 14.
*/
Structure Pet
Public Name As String
Public Age As Integer
End Structure
Sub MaxEx4()
' Create an array of Pet objects.
Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
New Pet With {.Name = "Boots", .Age = 4},
New Pet With {.Name = "Whiskers", .Age = 1}}
' Determine the "maximum" pet by passing a
' lambda expression to Max() that sums the pet's age
' and name length.
Dim max As Integer = pets.Max(Function(pet) _
pet.Age + pet.Name.Length)
' Display the result.
Console.WriteLine($"The maximum pet age plus name length is {max}")
End Sub
' This code produces the following output:
'
' The maximum pet age plus name length is 14
Açıklamalar
yöntemi, Max<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>) değerlerini karşılaştırmak için uygulamasını Single kullanırIComparable<T>.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max<TSource>(IEnumerable<TSource>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Genel bir dizideki en büyük değeri döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static TSource Max(System::Collections::Generic::IEnumerable<TSource> ^ source);
public static TSource Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source);
public static TSource? Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source);
static member Max : seq<'Source> -> 'Source
<Extension()>
Public Function Max(Of TSource) (source As IEnumerable(Of TSource)) As TSource
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IEnumerable<TSource>
En büyük değerini belirlemek için bir değer dizisi.
Döndürülenler
Dizideki en büyük değer.
Özel durumlar
source, null'e eşittir.
içindeki source hiçbir nesne veya IComparable arabirimini IComparable<T> uygulamaz.
Örnekler
Aşağıdaki kod örneği, bir nesne dizisindeki Max<TSource>(IEnumerable<TSource>) en yüksek değeri belirlemek için nasıl kullanılacağını IComparable<T> gösterir.
/// <summary>
/// This class implements IComparable to be able to
/// compare one Pet to another Pet.
/// </summary>
class Pet : IComparable<Pet>
{
public string Name { get; set; }
public int Age { get; set; }
/// <summary>
/// Compares this Pet to another Pet by
/// summing each Pet's age and name length.
/// </summary>
/// <param name="other">The Pet to compare this Pet to.</param>
/// <returns>-1 if this Pet is 'less' than the other Pet,
/// 0 if they are equal,
/// or 1 if this Pet is 'greater' than the other Pet.</returns>
int IComparable<Pet>.CompareTo(Pet other)
{
int sumOther = other.Age + other.Name.Length;
int sumThis = this.Age + this.Name.Length;
if (sumOther > sumThis)
return -1;
else if (sumOther == sumThis)
return 0;
else
return 1;
}
}
public static void MaxEx3()
{
Pet[] pets = { new Pet { Name="Barley", Age=8 },
new Pet { Name="Boots", Age=4 },
new Pet { Name="Whiskers", Age=1 } };
Pet max = pets.Max();
Console.WriteLine(
"The 'maximum' animal is {0}.",
max.Name);
}
/*
This code produces the following output:
The 'maximum' animal is Barley.
*/
' This class implements IComparable
' and has a custom 'CompareTo' implementation.
Class Pet
Implements IComparable(Of Pet)
Public Name As String
Public Age As Integer
''' <summary>
''' Compares Pet objects by the sum of their age and name length.
''' </summary>
''' <param name="other">The Pet to compare this Pet to.</param>
''' <returns>-1 if this Pet's sum is 'less' than the other Pet,
''' 0 if they are equal,
''' or 1 if this Pet's sum is 'greater' than the other Pet.</returns>
Function CompareTo(ByVal other As Pet) As Integer _
Implements IComparable(Of Pet).CompareTo
If (other.Age + other.Name.Length > Me.Age + Me.Name.Length) Then
Return -1
ElseIf (other.Age + other.Name.Length = Me.Age + Me.Name.Length) Then
Return 0
Else
Return 1
End If
End Function
End Class
Sub MaxEx3()
' Create an array of Pet objects.
Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
New Pet With {.Name = "Boots", .Age = 4},
New Pet With {.Name = "Whiskers", .Age = 1}}
' Find the "maximum" pet according to the
' custom CompareTo() implementation.
Dim max As Pet = pets.Max()
' Display the result.
Console.WriteLine($"The 'maximum' animal is {max.Name}")
End Sub
' This code produces the following output:
'
' The 'maximum' animal is Barley
Açıklamalar
türü TSource uygularsa IComparable<T>Max<TSource>(IEnumerable<TSource>) yöntemi, değerleri karşılaştırmak için bu uygulamayı kullanır. Aksi takdirde, tür TSource uygularsa IComparable, bu uygulama değerleri karşılaştırmak için kullanılır.
Bir başvuru türüyse ve kaynak dizisi boşsa TSource veya yalnızca olan nulldeğerleri içeriyorsa, bu yöntem döndürür null.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.
Ayrıca bkz.
Şunlara uygulanır
Max<TSource>(IEnumerable<TSource>, Func<TSource,Single>)
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
- Kaynak:
- Max.cs
Bir dizinin her öğesinde bir dönüşüm işlevi çağırır ve en büyük Single değeri döndürür.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static float Max(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, float> ^ selector);
public static float Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,float> selector);
static member Max : seq<'Source> * Func<'Source, single> -> single
<Extension()>
Public Function Max(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Single)) As Single
Tür Parametreleri
- TSource
öğelerinin sourcetürü.
Parametreler
- source
- IEnumerable<TSource>
En büyük değerini belirlemek için bir değer dizisi.
Döndürülenler
Dizideki en büyük değer.
Özel durumlar
source veya selector şeklindedir null.
source öğe içermiyor.
Örnekler
Aşağıdaki kod örneği, yansıtılan değerler dizisindeki en yüksek değeri belirlemek için nasıl kullanılacağını Max<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) gösterir.
Note
Bu kod örneği, yöntemin bu makalede açıklanan aşırı yüklemeden farklı bir aşırı yüklemesini kullanır. Örneği bu makalede açıklanan aşırı yüklemeye genişletmek için işlevin gövdesini selector değiştirin.
class Pet
{
public string Name { get; set; }
public int Age { get; set; }
}
public static void MaxEx4()
{
Pet[] pets = { new Pet { Name="Barley", Age=8 },
new Pet { Name="Boots", Age=4 },
new Pet { Name="Whiskers", Age=1 } };
int max = pets.Max(pet => pet.Age + pet.Name.Length);
Console.WriteLine(
"The maximum pet age plus name length is {0}.",
max);
}
/*
This code produces the following output:
The maximum pet age plus name length is 14.
*/
Structure Pet
Public Name As String
Public Age As Integer
End Structure
Sub MaxEx4()
' Create an array of Pet objects.
Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
New Pet With {.Name = "Boots", .Age = 4},
New Pet With {.Name = "Whiskers", .Age = 1}}
' Determine the "maximum" pet by passing a
' lambda expression to Max() that sums the pet's age
' and name length.
Dim max As Integer = pets.Max(Function(pet) _
pet.Age + pet.Name.Length)
' Display the result.
Console.WriteLine($"The maximum pet age plus name length is {max}")
End Sub
' This code produces the following output:
'
' The maximum pet age plus name length is 14
Açıklamalar
yöntemi, Max<TSource>(IEnumerable<TSource>, Func<TSource,Single>) değerlerini karşılaştırmak için uygulamasını Single kullanırIComparable<T>.
Bu yöntemi, selectorüyelerini sayısal bir türe ( özellikle source) projeleyen bir işlev sağlarsanız, rastgele değerler dizisine Single uygulayabilirsiniz.
Visual Basic sorgu ifadesi söz diziminde, Aggregate Into Max() yan tümcesi Max çağrısına dönüşür.