static void Main(string[] args)
        {
            string name = "asher";

            //方法1
            string str1 = "hello " + name;
            //方法2
            string str2 = string.Format("hello {0}", name);
            //方法3
            string str3 = $"hello {name}";

            Console.WriteLine(str1);
            Console.WriteLine(str2);
            Console.WriteLine(str3);
            Console.ReadKey();
        }

  运行结果:

 

C#字符串拼接的三种方式

 

相关文章:

  • 2021-11-23
  • 2021-11-28
  • 2021-08-30
  • 2021-10-30
  • 2021-06-09
  • 2022-12-23
猜你喜欢
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
  • 2021-08-11
  • 2021-11-20
  • 2022-12-23
相关资源
相似解决方案