MemoryExtensions.Count Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

Count<T>(Span<T>, T)

Counts the number of times the specified value occurs in the span.

Count<T>(ReadOnlySpan<T>, T, IEqualityComparer<T>)
Count<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, IEqualityComparer<T>)
Count<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Counts the number of times value occurs in span.

Count<T>(ReadOnlySpan<T>, T)

Counts the number of times the specified value occurs in the span.

Count<T>(Span<T>, ReadOnlySpan<T>)

Counts the number of times the specified value occurs in the span.

Count<T>(Span<T>, T)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Counts the number of times the specified value occurs in the span.

C#
[System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static int Count<T>(this Span<T> span, T value) where T : IEquatable<T>;
C#
public static int Count<T>(this Span<T> span, T value) where T : IEquatable<T>;

Type Parameters

T

The element type of the span.

Parameters

span
Span<T>

The span to search.

value
T

The value for which to search.

Returns

The number of times value was found in the span.

Attributes

Applies to

.NET 10 a ďalšie verzie
Produkt Verzie
.NET 8, 9, 10

Count<T>(ReadOnlySpan<T>, T, IEqualityComparer<T>)

C#
public static int Count<T>(this ReadOnlySpan<T> span, T value, System.Collections.Generic.IEqualityComparer<T>? comparer = default);

Type Parameters

T

Parameters

value
T

Returns

Applies to

.NET 10
Produkt Verzie
.NET 10

Count<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, IEqualityComparer<T>)

C#
public static int Count<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value, System.Collections.Generic.IEqualityComparer<T>? comparer = default);

Type Parameters

T

Parameters

Returns

Applies to

.NET 10
Produkt Verzie
.NET 10

Count<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Counts the number of times value occurs in span.

C#
public static int Count<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>;

Type Parameters

T

The element type of the span.

Parameters

span
ReadOnlySpan<T>

The span to search.

value
ReadOnlySpan<T>

The value for which to search.

Returns

The number of times value was found in span.

Applies to

.NET 10 a ďalšie verzie
Produkt Verzie
.NET 8, 9, 10

Count<T>(ReadOnlySpan<T>, T)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Counts the number of times the specified value occurs in the span.

C#
public static int Count<T>(this ReadOnlySpan<T> span, T value) where T : IEquatable<T>;

Type Parameters

T

The element type of the span.

Parameters

span
ReadOnlySpan<T>

The span to search.

value
T

The value for which to search.

Returns

The number of times value was found in the span.

Applies to

.NET 10 a ďalšie verzie
Produkt Verzie
.NET 8, 9, 10

Count<T>(Span<T>, ReadOnlySpan<T>)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Counts the number of times the specified value occurs in the span.

C#
[System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static int Count<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>;
C#
public static int Count<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>;

Type Parameters

T

The element type of the span.

Parameters

span
Span<T>

The span to search.

value
ReadOnlySpan<T>

The value for which to search.

Returns

The number of times value was found in the span.

Attributes

Applies to

.NET 10 a ďalšie verzie
Produkt Verzie
.NET 8, 9, 10