共用方式為


<add> 元素 <appSettings>

新增自訂應用程式設定。

<configuration>
  <appSettings>
    <add>

語法

<appSettings>
  <add key="Key of custom setting" value="Value of custom setting" />
</appSettings>

Attributes

Attribute Description
key 必要屬性。

指定要加入的鍵名稱。
value 必要屬性。

指定要加的鍵值。

父元素

父元素 Description
<appSettings> 包含自訂應用程式設定,例如檔案路徑、XML Web 服務 URL 或其他應用程式的自訂設定資訊。

子專案

None

Example

以下範例展示了如何為應用程式名稱新增自訂設定:

<appSettings>
  <add key="ApplicationName" value="MyApplication" />
</appSettings>

以下範例利用該 <add> 元素在 ASP.NET 應用程式中定義兩個相容性設定:

<appSettings>
  <add key="AppContext.SetSwitch:Switch.System.Globalization.NoAsyncCurrentCulture" value="true" />
  <add key="AppContext.SetSwitch:Switch.System.Uri.DontEnableStrictRFC3986ReservedCharacterSets" value="true" />
</appSettings>

另請參閱