Export (0) Print
Expand All

StronglyTypedResourceBuilder.VerifyResourceName Method

Note: This method is new in the .NET Framework version 2.0.

Generates a valid resource string based on the specified input string and code generator.

Namespace: System.Resources.Tools
Assembly: System.Design (in system.design.dll)

public:
static String^ VerifyResourceName (
	String^ key, 
	CodeDomProvider^ provider
)
public static String VerifyResourceName (
	String key, 
	CodeDomProvider provider
)
public static function VerifyResourceName (
	key : String, 
	provider : CodeDomProvider
) : String

Parameters

key

The string to verify and, if necessary, convert to a valid resource name.

provider

A CodeDomProvider object that specifies the target language to use.

Return Value

A valid resource name with any invalid tokens replaced with the underscore (_) character, or a null reference (Nothing in Visual Basic) if the string still contains invalid characters according to the language specified by the generator parameter.

Exception typeCondition

ArgumentNullException

key or generator is a null reference (Nothing in Visual Basic).

The VerifyResourceName method takes a string, compares each character with a set of invalid tokens based on the language specified by the generator parameter, and replaces any invalid characters with an underscore character (which is valid in resource name strings). The characters that will be replaced with an underscore are as follows:

' ' (space), U+00A0 (non-breaking space), '.' (period), ',' (comma), ';' (semicolon), '|', '~', '@', '#', '%', '^', '&', '*', '+', '-', '/', '\\', '<', '>', '?', '[', ']', '(', ')', '{', '}', '"' (quote), ''' (apostrophe), ':', and '!'.

NoteNote

Strongly-typed resources do not allow language keywords (such as if, for, and so on) as resource key names. However, the System.CodeDom design pattern allows the use of language keywords by prefixing the keyword with the underscore character. The VerifyResourceName method calls the CreateValidIdentifier method to enforce this design. Therefore, if you use a resource name that is the same as a language keyword, such as for, the name appears as _for in the generated strongly-typed resource class.

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0
Show:
© 2014 Microsoft