.NET/文字列宣言の先頭の@について
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../)
* C#でよくある文字列の先頭の@について [#n49de7d8]
C#のプログラムを見ると以下のようなString変数に文字列を代...
アットマーク(@)が先頭についていることが多いですよね。~
これは、エスケープ文字(\)を入力しなくても良いという利点が...
以下にサンプルコードと実行結果を紹介します。
//#htmlinsert(windev-top.html)
#contents
* @をつけた文字列と@が無い文字列 [#kee03449]
以下に@があるHello world文字列と@が無いHello world文字列...
メッセージボックスに文字列を表示します。
using System;
using System.Windows.Forms;
class Program
{
static void Main(string[] args)
{
String s1 = @"Hello\nworld\n";
String s2 = "Hello\nworld\n";
MessageBox.Show(s1, "s1");
MessageBox.Show(s2, "s2");
}
}
** 実行結果 [#sddf78d4]
以下のキャプチャの通り、@をつけると、\nが改行と認識されず...
@がない場合は、\nが改行として認識され表示されます。
|BGCOLOR(NAVY):COLOR(WHITE):''@あり''|BGCOLOR(NAVY):COLOR...
|&ref(01.png);|&ref(02.png);|
以上、C#で文字列定義の先頭に@が付いている場合の動作説明...
//#htmlinsert(windev-btm.html)
終了行:
#navi(../)
* C#でよくある文字列の先頭の@について [#n49de7d8]
C#のプログラムを見ると以下のようなString変数に文字列を代...
アットマーク(@)が先頭についていることが多いですよね。~
これは、エスケープ文字(\)を入力しなくても良いという利点が...
以下にサンプルコードと実行結果を紹介します。
//#htmlinsert(windev-top.html)
#contents
* @をつけた文字列と@が無い文字列 [#kee03449]
以下に@があるHello world文字列と@が無いHello world文字列...
メッセージボックスに文字列を表示します。
using System;
using System.Windows.Forms;
class Program
{
static void Main(string[] args)
{
String s1 = @"Hello\nworld\n";
String s2 = "Hello\nworld\n";
MessageBox.Show(s1, "s1");
MessageBox.Show(s2, "s2");
}
}
** 実行結果 [#sddf78d4]
以下のキャプチャの通り、@をつけると、\nが改行と認識されず...
@がない場合は、\nが改行として認識され表示されます。
|BGCOLOR(NAVY):COLOR(WHITE):''@あり''|BGCOLOR(NAVY):COLOR...
|&ref(01.png);|&ref(02.png);|
以上、C#で文字列定義の先頭に@が付いている場合の動作説明...
//#htmlinsert(windev-btm.html)
ページ名: