C# 文字列内のダブルクォーテーションを除去する

  • 作成日 2022.08.16
  • C#
C# 文字列内のダブルクォーテーションを除去する

C#で、文字列からダブルクォーテーションを除去するサンプルコードを記述してます。

環境

  • OS windows11 pro 64bit
  • Microsoft Visual Studio Community 2022 Version 17.2.6

ダブルクォーテーションを除去

ダブルクォーテーションを除去するには、「Replace」を使用して置換処理を行います。

using System;

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

            string str = "hello \"world \"!!";

            Console.WriteLine( str ); // hello "world "!!
            Console.WriteLine( str.Replace("\"", "") ); // hello world !!

        }
            
    }
}

実行結果