In This Article

SR Class

Provides access to the string resources of this assembly, also allowing for their customization.

public sealed class SR : SRBase
Inheritance:
object SRBase object

Remarks

Call the GetString(SRName, params object?[]) method to return a resolved resource string. If a custom string has been set for a specified string resource name, it will be returned. Otherwise, the default string resource value is returned.

If any of the resource strings are customized via a call to SetCustomString(SRName, string), it is best to do so before any other classes in this assembly are referenced, such as in the application startup.

Properties

ResourceManager

Gets the ResourceManager that provides the default resources.

public override ResourceManager ResourceManager { get; }

Property Value

ResourceManager:

The ResourceManager that provides the default resources.

Methods

ClearCustomStrings()

Removes all custom strings.

public static void ClearCustomStrings()

ContainsCustomString(SRName)

Returns whether a custom string is defined for the specified string resource.

public static bool ContainsCustomString(SRName name)
Parameter Type Description
name SRName

The name of the resource for which to search.

Returns

bool:

true if a custom string is defined for the specified string resource; otherwise, false.

GetCustomString(SRName)

Returns custom string that is stored for the specified string resource, if any.

public static string? GetCustomString(SRName name)
Parameter Type Description
name SRName

The name of the resource to get.

Returns

string:

The custom string that is stored for the specified string resource, if any.

GetString(SRName, params object?[])

Returns the resolved value of the specified string resource, by calling Format(IFormatProvider, string, params object[]) using supplied arguments.

public static string? GetString(SRName name, params object?[] args)
Parameter Type Description
name SRName

The name of the resource to get.

args object[]

The arguments to pass to Format(IFormatProvider, string, params object[]).

Returns

string:

The value of the resource localized for the caller's current culture settings. If a best match is not possible, null is returned.

RemoveCustomString(SRName)

Removes any custom string that is defined for the specified string resource.

public static void RemoveCustomString(SRName name)
Parameter Type Description
name SRName

The name of the resource to remove.

SetCustomString(SRName, string)

Sets a custom string value for the specified string resource.

public static void SetCustomString(SRName name, string value)
Parameter Type Description
name SRName

The name of the resource to set.

value string

The value of the resource to set.

Inherited Members

Extension Methods