C# 文字列と文字列を結合する

  • 作成日 2020.12.24
  • 更新日 2022.03.04
  • C#
C# 文字列と文字列を結合する

C#で、Concatを使用して、文字列と文字列を結合するサンプルコードを記述してます。

環境

  • OS windows10 pro 64bit
  • Microsoft Visual Studio Community 2019 Version 16.7.1

Concat使い方

Concatを使用すると、文字列と文字列を結合することが可能です。

ここでは、文字列「str」と「” World”, “!!”」を結合してます。

using System;
using System.Collections.Generic;

namespace testapp
{
    class Program
    {
        static void Main(string[] args)
        {

            string str = "Hello";
            
            Console.WriteLine(string.Concat(str, " World", "!!"));
            // Hello World!!

            Console.ReadKey();
        }
    }
}