[研究][C#] 空字串 string.Empty 和 "" 比較測試
2200-03-19
String.Empty 欄位 (System) | Microsoft Docs
https://docs.microsoft.com/zh-tw/dotnet/api/system.string.empty?view=net-6.0
表示空字串。 此欄位為唯讀。
what is the difference between String.Empty and "" ?
https://social.msdn.microsoft.com/Forums/en-US/9977e45f-c8c5-4a8f-9e02-12f74c1c4579/what-is-the-difference-between-stringempty-and-quotquot-?forum=csharplanguage
protected void Page_Load(object sender, EventArgs e) { string str1 = ""; string str2 = string.Empty; if (str1 == str2) Label1.Text = "Same"; else Label1.Text = "Not Same"; str1 = "test"; str2 = "test"; } |
結果 Same
(完)
沒有留言:
張貼留言