반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- Excel
- list
- string
- Redshift
- Tkinter
- Java
- matplotlib
- Github
- hive
- dataframe
- PySpark
- c#
- math
- Google Spreadsheet
- numpy
- GIT
- Google Excel
- PostgreSQL
- google apps script
- Python
- 파이썬
- Kotlin
- PANDAS
- Apache
- SQL
- Mac
- array
- django
- gas
Archives
- Today
- Total
달나라 노트
C# : substring (문자열 자르기) 본문
728x90
반응형
substring은 특정 위치부터 문자열을 잘라 return합니다.
using System;
class MyProgram
{
static void Main()
{
string test1 = "Apple";
string sub_test1 = test1.Substring(1);
Console.WriteLine(sub_test1);
string sub_test2 = test1.Substring(1, 3);
Console.WriteLine(sub_test2);
}
}
-- Result
pple
ppl
string sub_test1 = test1.Substring(1);
test1의 글자에서 index=1 위치부터 끝에 있는 부분만 reutrn합니다.
string sub_test2 = test1.Substring(1, 3);
test1의 글자에서 index=1 위치부터 index=3 사이에 있는 부분만 return합니다.
여기서 마지막 부분인 index=3 위치에 존재하는 문자도 포함되어 return됩니다.
728x90
반응형
'C# > C#' 카테고리의 다른 글
C# : switch ~ case (조건문) (0) | 2022.03.23 |
---|---|
C# : if ~ else if ~ else (조건문), 한줄 if문 (0) | 2022.03.23 |
C# : 문자열 indexing (0) | 2022.03.23 |
C# : interpolation (문자열 format 기능 사용하기) (0) | 2022.03.23 |
C# : +, Concat (문자열 연결) (0) | 2022.03.23 |
Comments