기본 문자열 string
사용하기 간단하고 MFC에 있는 CString과 많이 비슷하다
하지만 좀더 편한 감은 있다.
words.누르게 되면 나오는 다양한 함수를 통해서 속성을 확인할 수 있다
아래 코드의 예제(주석포함)을 실행해 보면 어떤 식으로 돌아가는지 확인 할 수 있다.
split의 경우에는 배열로 값을 리턴 받기 때문에 배열을 선언해서 받는다.
그리고 foreach문을 사용하여 출력하였다
그 외에 내용들은 간단하게 한줄로 그 기능들을 나타낸다
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string words = "hello world!";
Console.WriteLine(words.Substring(words.IndexOf('w')));
//Console.WriteLine(words.Length);
//string[] newWords = words.Split(' ');
// foreach (var word in newWords)
// {
// Console.WriteLine(word);
// }
//Console.WriteLine(words.IndexOf('w'));
}
}
}
댓글