Megosztás a következőn keresztül:


MediaTypeHeaderValueComparer.Compare Method

Definition

Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.

public:
 virtual int Compare(Microsoft::Net::Http::Headers::MediaTypeHeaderValue ^ mediaType1, Microsoft::Net::Http::Headers::MediaTypeHeaderValue ^ mediaType2);
public int Compare (Microsoft.Net.Http.Headers.MediaTypeHeaderValue mediaType1, Microsoft.Net.Http.Headers.MediaTypeHeaderValue mediaType2);
public int Compare (Microsoft.Net.Http.Headers.MediaTypeHeaderValue? mediaType1, Microsoft.Net.Http.Headers.MediaTypeHeaderValue? mediaType2);
abstract member Compare : Microsoft.Net.Http.Headers.MediaTypeHeaderValue * Microsoft.Net.Http.Headers.MediaTypeHeaderValue -> int
override this.Compare : Microsoft.Net.Http.Headers.MediaTypeHeaderValue * Microsoft.Net.Http.Headers.MediaTypeHeaderValue -> int
Public Function Compare (mediaType1 As MediaTypeHeaderValue, mediaType2 As MediaTypeHeaderValue) As Integer

Parameters

Returns

Implements

Examples

If we had a list of media types (comma separated): { text/;q=0.8, text/+json;q=0.8, /;q=1, /;q=0.8, text/plain;q=0.8 } Sorting them using Compare would return: { /;q=0.8, text/;q=0.8, text/+json;q=0.8, text/plain;q=0.8, /;q=1 }

Remarks

Performs comparisons based on the arguments' quality values (aka their "q-value"). Values with identical q-values are considered equal (i.e. the result is 0) with the exception that suffixed subtype wildcards are considered less than subtype wildcards, subtype wildcards are considered less than specific media types and full wildcards are considered less than subtype wildcards. This allows callers to sort a sequence of MediaTypeHeaderValue following their q-values in the order of specific media types, subtype wildcards, and last any full wildcards.

Applies to