MimeTypeParameterEquals(MimeTypeParameter) Method

Determines if the content of other is equal to that of the current instance.

Definition

Namespace: FolkerKinzel.MimeTypes
Assembly: FolkerKinzel.MimeTypes (in FolkerKinzel.MimeTypes.dll) Version: 1.0.0+7dd5ca03f25d4802263abb2083f9c7add2cb51ec
C#
public bool Equals(
	MimeTypeParameter? other
)

Parameters

other  MimeTypeParameter
A MimeTypeParameter object to compare with or null.

Return Value

Boolean
true if the content of other is equal to that of the current instance.

Implements

IEquatableTEquals(T)

Example

Comparison of MimeType instances:

C#
using FolkerKinzel.MimeTypes;

namespace Examples;

public static class EqualityExample
{
    public static void Example()
    {
        const string media1 = "text/plain; charset=us-ascii";
        const string media2 = "TEXT/PLAIN";
        const string media3 = "TEXT/HTML";
        const string media4 = "text/plain; charset=iso-8859-1";
        const string media5 = "TEXT/PLAIN; CHARSET=ISO-8859-1";
        const string media6 = "text/plain; charset=iso-8859-1; other-parameter=other_value";
        const string media7 = "text/plain; OTHER-PARAMETER=other_value; charset=ISO-8859-1";
        const string media8 = "text/plain; charset=iso-8859-1; other-parameter=OTHER_VALUE";

        if (MimeType.Parse(media1) == MimeType.Parse(media2) &&
            MimeType.Parse(media2) != MimeType.Parse(media3) &&
            MimeType.Parse(media2) != MimeType.Parse(media4) &&
            MimeType.Parse(media2).Equals(MimeType.Parse(media4), ignoreParameters: true) &&
            MimeType.Parse(media4) == MimeType.Parse(media5) &&
            MimeType.Parse(media4) != MimeType.Parse(media6) &&
            MimeType.Parse(media6) == MimeType.Parse(media7) &&
            MimeType.Parse(media6) != MimeType.Parse(media8))
        {
            Console.WriteLine("Success");
        }
        else
        {
            Console.WriteLine("Error");
        }
    }
}
// Console Output: Success

See Also