EventLogEntry.ReplacementStrings 屬性

定義

取得與事件記錄檔項目相關聯的取代字串。

public:
 property cli::array <System::String ^> ^ ReplacementStrings { cli::array <System::String ^> ^ get(); };
public string[] ReplacementStrings { get; }
member this.ReplacementStrings : string[]
Public ReadOnly Property ReplacementStrings As String()

屬性值

String[]

陣列,保留儲存於事件項目中的取代字串。

備註

此屬性只會擷取專案的取代字串。 若要擷取完整訊息,請閱讀 Message 屬性。

ReplacementStrings屬性包含事件記錄檔專案中使用的當地語系化取代字串版本。 如果您提供資源檔,其中包含應用程式每個目的語言中的字串,您可以使用該電腦上所使用的語言發出事件記錄檔訊息。 若要這樣做,請為包含取代字串的資源元件建立 類別的 ResourceManager 實例。 建構函式的第一個參數 ResourceManager(String, Assembly) 會識別要使用的資源元件。 GetString使用該實例的 方法來提供記錄事件的當地語系化訊息。 下列程式碼會自動將訊息設定為目前文化特性的語言。

ResourceManager LocRM = new ResourceManager("ReplacementStrings.TestStrings",   
      typeof(Program).Assembly);  
EventLog e1 = new EventLog("LocTest", "MyMachine", "LocTest");  
// Get the string associated with the current culture.  
e1.WriteEntry(LocRM.GetString("strMessage"),  
   EventLogEntryType.Information);  

適用於

另請參閱