MediaTypeHeaderValue Class
Represents a media type header value.
This class represents a media type, such as "text/plain" or "application/json". It includes the media type itself (e.g., "text/html") and any parameters associated with it (e.g., "charset=utf-8").
This class represents a media type, such as "text/plain" or "application/json". It includes the media type itself (e.g., "text/html") and any parameters associated with it (e.g., "charset=utf-8").
Namespace: System.Net.Http.Headers
Assembly: System.Net.Http.dll
Syntax
public sealed class MediaTypeHeaderValue : IEquatable<MediaTypeHeaderValue>, ICloneable
Constructors
-
MediaTypeHeaderValue(string mediaType)
public MediaTypeHeaderValue(string mediaType)
Initializes a new instance of the
MediaTypeHeaderValueclass for the specified media type. -
MediaTypeHeaderValue(MediaTypeHeaderValue other)
public MediaTypeHeaderValue(MediaTypeHeaderValue other)
Initializes a new instance of the
MediaTypeHeaderValueclass by copying values from another instance.
Properties
-
CharSet
public string CharSet { get; set; }
Gets or sets the character set of the media.
-
MediaType
public string MediaType { get; set; }
Gets or sets the media type.
-
Parameters
public System.Collections.Generic.ICollection<System.Net.Http.Headers.NameValueHeaderValue> Parameters { get; }
Gets a collection of the parameters associated with the media type.
Methods
-
Equals(object obj)
public override bool Equals(object obj)
Determines whether the specified object is equal to the current object.
-
Equals(MediaTypeHeaderValue other)
public bool Equals(MediaTypeHeaderValue other)
Determines whether the specified media type header value is equal to the current object.
-
GetHashCode()
public override int GetHashCode()
Serves as the default hash function.
-
Parse(string input)
public static MediaTypeHeaderValue Parse(string input)
Parses a string into a
MediaTypeHeaderValueinstance. -
ToString()
public override string ToString()
Returns a string that represents the current object.
-
TryParse(string input, out MediaTypeHeaderValue value)
public static bool TryParse(string input, out MediaTypeHeaderValue value)
Converts the specified string to its
MediaTypeHeaderValueequivalent. Returnstrueif conversion succeeds orfalseotherwise.
Implements
IEquatable<MediaTypeHeaderValue>, ICloneable