Namespace: System.Net.Http.Headers
Assembly: System.Net.Http.Headers.dll
Represents a Pragma header value. The Pragma header is an extension header, which means it can be used for non-standard header information.
public sealed class PragmaHeaderValue
Initializes a new instance of the PragmaHeaderValue class.
Initializes a new instance of the PragmaHeaderValue class with the specified Pragma header name.
| Name | Type | Description |
|---|---|---|
name |
string | The name of the Pragma header. |
Initializes a new instance of the PragmaHeaderValue class with the specified Pragma header name and value.
| Name | Type | Description |
|---|---|---|
name |
string | The name of the Pragma header. |
value |
string | The value of the Pragma header. |
string
Gets the name of the Pragma header.
string
Gets the value of the Pragma header.
string
Returns the string representation of the current Pragma header value.
Parses a Pragma header value from the specified string.
| Name | Type | Description |
|---|---|---|
input |
string | A string that contains the value to parse. |
A PragmaHeaderValue object.
Tries to parse a Pragma header value from the specified string.
| Name | Type | Description |
|---|---|---|
input |
string | A string that contains the value to parse. |
value |
out PragmaHeaderValue | When this method returns, contains the parsed PragmaHeaderValue object if the parsing succeeded, or null if it failed. |
true if the string was parsed successfully; otherwise, false.
using System.Net.Http.Headers;
// Creating a Pragma header value
var pragma = new PragmaHeaderValue("no-cache");
Console.WriteLine(pragma.ToString()); // Output: no-cache
// Creating a Pragma header value with a specific value
var noStorePragma = new PragmaHeaderValue("cache-control", "no-store");
Console.WriteLine(noStorePragma.ToString()); // Output: cache-control=no-store
// Parsing a Pragma header value
string input = "my-custom-pragma=some-value";
if (PragmaHeaderValue.TryParse(input, out PragmaHeaderValue parsedPragma))
{
Console.WriteLine($"Parsed Name: {parsedPragma.Name}");
Console.WriteLine($"Parsed Value: {parsedPragma.Value}");
}
else
{
Console.WriteLine("Failed to parse Pragma header value.");
}