C#/Problems
6. 문자열에 특정 문자열이 포홤되는 지 확인하기( Contains( ) )
dev_sr
2020. 4. 21. 15:18
1. 코드
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Study_013_1
{
class App
{
public App()
{
string s1 = "the Lazy dog, fox";
string s2 = "fox";
bool b;
b = s1.Contains(s2);
//s2가 s1에 포함되면 true / 포함되지 않으면 false
Console.WriteLine("{0}", b); //True
}
}
}
|
2. 결과값