프로그래밍/C#
c# 문장에서 특정 문자 가져오기
뽀로로친구에디
2022. 8. 22. 11:04
c# substring과 indexof를 이용하여 특정 문자들 가져오기
C#에서 문장의 특정 글자를 가져오기 위해 Substring과 IndexOf를 이용해보겠습니다.
아래 코드는 ㉠을 시작으로 3번째 글자까지 가져오는 코드입니다.
Substring(시작위치, 몇번째까지 가져오기);
string text = "있니다 ㉠ ABCDEF ㉡";
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = text.Substring(text.IndexOf("㉠"), 3);
}
㉠을 시작으로 3번째 글자인 A까지 출력이 되었습니다.
- YouTube
www.youtube.com