C#

[C#]Split() 지정한 문자를 기준으로 문자열 분리

데브프로그라 2024. 2. 22. 21:57
반응형

● string[] Split(char[] separator)

- separator : 분리문자

 

using System;
namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "제품군|코드번호|자재번호";
            string[] strAr = str.Split('|');
            foreach (string strValue in strAr)
            {
                Console.WriteLine(strValue);
            }
        }
    }
}

 

결과:

제품군

코드번호

자재번호

 

반응형

/* 코드복사 버튼 */ pre { position: relative; overflow: visible; } pre .copy-button { opacity: 0; position: absolute; right: 8px; top: 4px; padding: 6px 18px; color: rgb(255, 255, 255); background: rgba(255, 223, 0, 0.6); border-radius: 5px; transition: opacity .3s ease-in-out; } pre:hover .copy-button { opacity: 1; } pre .copy-button:hover { color: #eee; transition: all ease-in-out 0.3s; } pre .copy-button:active { color: #33f; transition: all ease-in-out 0.1s; } .copy-message:before { content: attr(copy-message); position: absolute; left: -95px; top: 0px; padding: 6px 18px; color: #fff; background: rgba(255, 223, 0, 0.6); border-radius: 5px; } /* 코드복사 버튼 END */