StringBuilder做函数参数:

 static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            Hello(sb);//StringBuilder做为方法参数使用时不需要赋值,其使用相当于 out str
            Console.WriteLine(sb.ToString());
            string str;
            World(out str);
            Console.WriteLine(str);
            Console.ReadKey();
        }

        public static void Hello(StringBuilder sb)
        {
            sb.Append("StringBuilder Hello World");
        }

        public static void World(out string str)
        {
            str = "string Hello World";
        }

输出结果:

StringBuilder做函数参数

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
  • 2021-09-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
  • 2021-07-25
  • 2022-01-20
  • 2022-12-23
相关资源
相似解决方案