투케이2K

94. (C#/NET) [Mac Os] [문법] StringBuilder 생성 및 Insert 사용해 특정 번지 지정, 문자열 삽입 수행 본문

C샵 (NET)

94. (C#/NET) [Mac Os] [문법] StringBuilder 생성 및 Insert 사용해 특정 번지 지정, 문자열 삽입 수행

투케이2K 2024. 3. 17. 19:25
반응형

[개발 환경 설정]

개발 언어 : C# / NET

 

[소스 코드]

using System;
using System.Collections;
using System.Data;
using System.Diagnostics.Tracing;
using System.Text;
using System.Web;

namespace testProject {


    // [프로그램 동작 클래스]
    class Program {

        // [메소드 수행]
        static void Main(string[] args){

            // [StringBuilder 선언 수행]
            StringBuilder stringBuilder = new StringBuilder();


            // [Append = 연속 문자열 추가] : [AppendLine = 문자열 행 바꿈을 하면서 추가]
            stringBuilder.Append("Hello");
            stringBuilder.Append("Twok");
            stringBuilder.Append("Nice");


            // [Insert 사용해 특정 번지에 문자열 삽입 수행] : [문자열은 0번지 부터 시작]
            stringBuilder.Insert(5, "투케이");
            

            // [결과 출력]
            Console.WriteLine($"");
            Console.WriteLine($"------------------------------------------");
            Console.WriteLine($"[Main] : [Log]");
            Console.WriteLine($"------------------------------------------");
            Console.WriteLine($"stringBuilder : {stringBuilder}");
            Console.WriteLine($"------------------------------------------");
            Console.WriteLine($"");

        }

    }

}
 

[결과 출력]


 
반응형
Comments