ResourceSet.GetString 方法

定義

傳回具有指定名稱的 String 資源。Returns a String resource with a specified name.

多載

GetString(String)

以指定的名稱搜尋 String 資源。Searches for a String resource with the specified name.

GetString(String, Boolean)

如果要求的話,以不區分大小寫的指定名稱搜尋 String 資源。Searches for a String resource with the specified name in a case-insensitive manner, if requested.

GetString(String)

以指定的名稱搜尋 String 資源。Searches for a String resource with the specified name.

public:
 virtual System::String ^ GetString(System::String ^ name);
public virtual string GetString (string name);
abstract member GetString : string -> string
override this.GetString : string -> string
Public Overridable Function GetString (name As String) As String

參數

name
String

要搜尋的資源名稱。Name of the resource to search for.

傳回

資源的值,如果值為 StringThe value of a resource, if the value is a String.

例外狀況

name 參數為 nullThe name parameter is null.

name 所指定的資源不是 StringThe resource specified by name is not a String.

物件已關閉或已處置。The object has been closed or disposed.

GetString(String, Boolean)

如果要求的話,以不區分大小寫的指定名稱搜尋 String 資源。Searches for a String resource with the specified name in a case-insensitive manner, if requested.

public:
 virtual System::String ^ GetString(System::String ^ name, bool ignoreCase);
public virtual string GetString (string name, bool ignoreCase);
abstract member GetString : string * bool -> string
override this.GetString : string * bool -> string
Public Overridable Function GetString (name As String, ignoreCase As Boolean) As String

參數

name
String

要搜尋的資源名稱。Name of the resource to search for.

ignoreCase
Boolean

表示指定名稱的大小寫是否應該忽略。Indicates whether the case of the case of the specified name should be ignored.

傳回

資源的值,如果值為 StringThe value of a resource, if the value is a String.

例外狀況

name 參數為 nullThe name parameter is null.

name 所指定的資源不是 StringThe resource specified by name is not a String.

物件已關閉或已處置。The object has been closed or disposed.

備註

如果ignoreCase參數的值為true, 則名稱為 "resource" 的資源相當於名稱為 "resource" 的資源。If the value of the ignoreCase parameter is true, a resource with the name "Resource" is equivalent to the resource with the name "resource". 不過要注意的是, 這個方法一律會使用CultureInfo.InvariantCulture來執行不區分大小寫的字串比較。Note, however, that this method always performs case-insensitive string comparisons using CultureInfo.InvariantCulture. 優點是不論文化特性為何, 這個方法所執行之不區分大小寫字串比較的結果在所有電腦上都相同。The advantage is that results of case-insensitive string comparisons performed by this method are the same on all computers regardless of culture. 缺點是結果與所有文化特性的大小寫規則不一致。The disadvantage is that the results are not consistent with the casing rules of all cultures.

例如, 土耳其文字母有兩個版本的字元 I: 一個包含一個點, 一個沒有點。For example, the Turkish alphabet has two versions of the character I: one with a dot and one without a dot. 在土耳其文中, I (Unicode 0049) 字元會被視為不同字元ı (Unicode 0131) 的大寫版本。In Turkish, the character I (Unicode 0049) is considered the uppercase version of a different character ı (Unicode 0131). 字元 i (Unicode 0069) 被視為另一個字元 i (Unicode 0130) 的小寫版本。The character i (Unicode 0069) is considered the lowercase version of yet another character İ (Unicode 0130). 根據這些大小寫規則, 不區分大小寫的字元 i (Unicode 0069) 和 I (Unicode 0049) 的字串比較應該會失敗, 因為文化特性 "tr-TR" (土耳其文中為土耳其文)。According to these casing rules, a case-insensitive string comparison of the characters i (Unicode 0069) and I (Unicode 0049) should fail for the culture "tr-TR" (Turkish in Turkey). 使用方法並ignoreCase將設定為true, 此比較會成功。 GetStringUsing the GetString method with ignoreCase set to true, this comparison succeeds.

適用於