본문 바로가기

.NET/C# Basic

C# 문자열 관련 Split() , subString() 관련

반응형
using System;
using System.Collections.Generic;
using System.Text;

namespace splittest
{
class Program
{
static void Main(string[] args)
{
string[] splitedData = {};     //짜를 떼이터를 가변 배열로 선언해야징 ㅎㅎㅎ
string orignData = "나 다시|돌아갈래!|박하사탕";
string abcStr = "abcdefghijklmnopqrstuvwxyz";
splitedData = orignData.Split('|');    //  배열에 '|'을 기준으로 담는다
for (int i = 0; i < splitedData.Length; i++)
{
Console.WriteLine("배열길이 :  {2} 값의길이 : {0} 값 : {1}", splitedData[i].Length, splitedData[i], splitedData.Length);
}
Console.WriteLine("!!!!!!!!  {0}  !!!!!!!!", abcStr.Substring(2));
Console.WriteLine("!!!!!!!!  {0}  !!!!!!!!", abcStr.Substring(5,10));
}ss
}
}