1.忽略轉義字元 \
2.字串跨行string str =
"c:\\windows\\system32"
;string str =
@"c:\windows\system32"
;
3.將關鍵字作為識別符號使用string str =
"line one"
+"line two"
+"line three"
+"line fore"
;string str =
@"line one
line two
line three
line fore"
;
c#是不允許關鍵字作為識別符號(類名、變數名、方法名、表空間名等)使用的,但如果加上@之後就可以了
簡化string.format()寫法,行駛format的作用int @int=1
;
可簡寫為string name =
"kaisarh"
;int age =0;
string str_1 =
string
.format
("my name is ,i`m years old"
,name,age)
;
如果在字串中想要輸出引號,不管是"還是』,都需要在其前面加乙個轉義字元\string str_1 = $"my name is ,i`m years old"
;
如果在字串中像輸出{},需要使用}
C 和 符號用法
用法 比如說bai你在全域性定義了乙個變du量str,然後在函式裡面zhi又定義了這個str名字的變dao量的,這個時候你要是在函式裡面直接寫str,那麼就是訪問的函式內部的變數的。無法訪問外部變數的。這是正常的現象的。但是如果你想訪問外部變數的話,那麼就可以使用 str來訪問的。就不會是訪問內部變...
C語言中的強符號和弱符號介紹
之前在extern c 用法詳解中已經提到過符號的概念,它是編譯器對變數和函式的一種標記,編譯器對c和c 在生產符號時規則也是不一樣的,符號除了本身名字的區別外,還有強符號和弱符號之分 我們先看一段簡單的 複製 如下 test.c void hello int main 很顯然,這段 是沒法鏈結通過...
C 的符號用法 ?問號用法
在字串前加 相當於對string format 的簡化 如 int m a 1 int m b 2 使用string format console.writeline string format this is a this is b m a,m b 使用了 就可以在原來佔位符的地方直接用引數代替 ...