MimeContentType Class

The value of a Content-Type header ([RFC 2045] 5): a media type, a subtype and parameters.

public sealed class MimeContentType

Constructors

NameDescription
MimeContentType(string, string)Initializes a new instance of the MimeContentType class.

MimeContentType(string, string)

MimeContentType.cs

Initializes a new instance of the MimeContentType class.

public MimeContentType(string mediaType, string mediaSubtype)

Parameters

mediaType string
The media type, such as text.
mediaSubtype string
The media subtype, such as plain.

Properties

NameDescription
BoundaryGets or sets the boundary parameter of a multipart type.
CharsetGets or sets the charset parameter.
MediaSubtypeGets or sets the media subtype, such as plain or mixed.
MediaTypeGets or sets the media type, such as text or multipart.
MimeTypeGets the type and the subtype, such as text/plain.
NameGets or sets the name parameter, the file name that old clients give to an attachment.
ParametersGets the parameters, with case-insensitive names.

Gets or sets the boundary parameter of a multipart type.

public string? Boundary { get; set; }

Property value

string?

Gets or sets the charset parameter.

public string? Charset { get; set; }

Property value

string?

MediaSubtype

MimeContentType.cs

Gets or sets the media subtype, such as plain or mixed.

public string MediaSubtype { get; set; }

Property value

string

Gets or sets the media type, such as text or multipart.

public string MediaType { get; set; }

Property value

string

Gets the type and the subtype, such as text/plain.

public string MimeType { get; }

Property value

string

Gets or sets the name parameter, the file name that old clients give to an attachment.

public string? Name { get; set; }

Property value

string?

Gets the parameters, with case-insensitive names.

public IDictionary<string, string> Parameters { get; }

Methods

NameDescription
IsMimeType(string, string)Returns whether the type is the given type and subtype, ignoring case.
Parse(string)Parses the value of a Content-Type header. An invalid value gives text/plain ([RFC 2045] 5.2).
ToString()Returns the value of the header: the type, the subtype and the parameters.

IsMimeType(string, string)

MimeContentType.cs

Returns whether the type is the given type and subtype, ignoring case.

public bool IsMimeType(string mediaType, string mediaSubtype)

Parameters

mediaType string
The media type, or * for any type.
mediaSubtype string
The media subtype, or * for any subtype.

Returns

bool true when the type matches.

Parse(string)

MimeContentType.cs

Parses the value of a Content-Type header. An invalid value gives text/plain ([RFC 2045] 5.2).

public static MimeContentType Parse(string value)

Parameters

value string
The value of the header, with its encoded words.

Returns

MimeContentType The content type.

Returns the value of the header: the type, the subtype and the parameters.

public override string ToString()

Returns

string The value of the header.