1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

thisを使って取得できる値

Posted at

はじめに

thisを使って値を取得する際に取得できるものとできないものがあって困った点がありました。

取得できる値

あらかじめwebconfigに記載しておく。

add key="abc" value="100"

下記のように宣言する。

private readonly string dummy = ConfigurationSettings.AppSettings["abc"];

ここでthisを使用すると値が取得できます。

this.dummy

結果

webconfigで指定した値の'100'を取得することが可能です。

取得できない値

例えばラベル値の場合は'System.Web.UI.WebControls.Label'が取得されて値は取得できません。

結論

固定値の場合にthisを使用するのは便利ですので、webconfigとあわせてうまく使いましょう。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?