반응형
<코드 입력>
namespace Test
{
internal class Program
{
static void Main(string[] args)
{
// 원본
string str = "abcdef";
Console.WriteLine(str);
// 제거할 문자 내용
string tmp1 = "abc";
string tmp2 = "f";
// abcdef 문자열에서 abc 문자열을 제거
// Replace : 문자열 치환
string result = str.Replace(tmp1, "");
Console.WriteLine(result);
result = str.Replace(tmp2, "");
Console.WriteLine(result);
// ef를 aaaaaa로 변경
result = str.Replace("ef", "aaaaaa");
Console.WriteLine(result);
}
}
}
<결과 확인>
728x90
반응형
'연습문제 > C# 연습문제' 카테고리의 다른 글
11. 문자열 접두사 비교하기 (0) | 2023.08.16 |
---|---|
10. 공백(다중) 처리하기 (0) | 2023.08.06 |
9. 제곱근과 제곱수 (0) | 2023.08.06 |
8. 문자열 치환, 문자열 변경(특정문자) (0) | 2023.08.06 |
7. 대소문자 구별없이 비교하기(Contains) (0) | 2023.08.03 |
6. 대소문자 변환 (0) | 2023.08.03 |
5. 배열에 숫자 순서대로 채우기 (0) | 2023.08.02 |
4. 문자열에서 숫자 찾기 (0) | 2023.07.29 |
3. 숫자의 각 자릿수 더하기 (0) | 2023.07.23 |
2. 배열 뒤집기 (0) | 2023.07.23 |