Login
Sign Up For Free
English
中文 (繁體)
中文 (香港)
中文 (简体)
日本語
Filipino
Bahasa Indonesia
Bahasa Melayu
Pусский
Português (Brasil)
Magyar
Français
Español
Deutsch
Čeština
العربية
Català
Dansk
Ελληνικά
فارسی
Suomi
Gaeilge
Hindi
עברית
Hrvatski
Italiano
Norsk bokmål
Nederlands
한국어
Polski
Română
Slovenský
Svenska
Türkçe
українська
беларуская
ไทย
Standard view
玖。|ू •̀ω•́ )۶
1 months ago
@Edit 1 months ago
【C#】
0324
今日進度:
C# String:
Access Strings, Special Characters
.
荒廢了好多天ㄛ
今天進度也少少的
latest #17
掰噗~
說
1 months ago
哇哩咧
玖。|ू •̀ω•́ )۶
1 months ago
復習復習:
玖。|ू •̀ω•́ )۶
1 months ago
using System;
namespace
應該還記得ㄅ
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(“好險第二行差點記不起來ㄛ”);
}
}
}
立即下載
玖。|ू •̀ω•́ )۶
1 months ago
=
玖。|ू •̀ω•́ )۶
1 months ago
@Edit 1 months ago
接上
6.
字串變數
[ ]:擷取指定位數的字元
-
string myString=“Hello World”;
Console.WriteLine(
myString
[0]
);
// 擷取
第一位
:H
Console.WriteLine(
myString
[1]
);
// 擷取
第二位
:e
玖。|ू •̀ω•́ )۶
1 months ago
@Edit 1 months ago
7.
字串變數
.IndexOf(“ “):
找到擷取字母是第幾位
-
Console.WriteLine(
myString
.IndexOf(“W”)
);
// =7(第7位字元)
玖。|ू •̀ω•́ )۶
1 months ago
8.
字串變數
.Substring():
從指定的字元位置開始得到新字串
常與 IndexOf變成組合技一起使用
-
int charPos =
myString
.IndexOf(“W”)
;
string secString =
myString
.Substring(charPos)
;
Console.WriteLine(secString);
// = World
玖。|ू •̀ω•́ )۶
1 months ago
@Edit 1 months ago
試著合併以上三行
Console.WriteLine(
myString.Substring(myString.IndexOf(“W”))
);
玖。|ू •̀ω•́ )۶
1 months ago
@Edit 1 months ago
也可以用座標表示新字串範圍
-
string bio = “Kalafina is special.”
string groupName =
bio
.Substring(0,8)
;
Console.WriteLine(groupName);
// = Kalafina
玖。|ू •̀ω•́ )۶
1 months ago
@Edit 1 months ago
9. 利用
\
(backslash) :
顯示 / 或 ‘ 或 “
還有一些特殊妙用(?)
玖。|ू •̀ω•́ )۶
1 months ago
@Edit 1 months ago
\”
-
Console.WriteLine(“
\”
Kalafina
\”
是個三人組合”);
// =
“
Kalafina
”
是個三人組合
玖。|ू •̀ω•́ )۶
1 months ago
@Edit 1 months ago
\’
-
Console.WriteLine(“It
\’
s a wonderful day.”);
// = It
’
s a wonderful day.
玖。|ू •̀ω•́ )۶
1 months ago
@Edit 1 months ago
\\
-
Console.WriteLine(“The character
\\
is called backslash.”);
// = The character
\
is called backslash.
玖。|ू •̀ω•́ )۶
1 months ago
@Edit 1 months ago
\n:換行
-
Console.WriteLine(“Hello
\n
World”);
// =
Hello
World
玖。|ू •̀ω•́ )۶
1 months ago
@Edit 1 months ago
\t:右退一格tab
-
Console.WriteLine(“Hello
\t
World”);
// = Hello
World
玖。|ू •̀ω•́ )۶
1 months ago
\b:退格鍵backspace
-
Console.WriteLine(“Hel
\b
lo World”);
// =
Helo
World
玖。|ू •̀ω•́ )۶
1 months ago
@Edit 1 months ago
=
很多很多的場外資料:
C# Substring 定義及七種用法 - JOBDAREN 工作達人
Day18-C#-最常用的陣列!處理字串的一百種方法~(組合、切割、取代、擷取、尋找、修改) - iT ...
back to top
delete
reply
edit
cancel
cancel