赞
踩
just pass the string object to the StringBuilder class constructor
using System; using System.Text; class GFG { // Main Method public static void Main(String[] args) { String str = "Geeks"; // conversion from String object // to StringBuilder StringBuilder sbl = new StringBuilder(str); sbl.Append("ForGeeks"); Console.WriteLine(sbl); } }
using ToString() method
using System; using System.Text; class GFG { // Main Method public static void Main(String[] args) { StringBuilder sbdr = new StringBuilder("Builder"); // conversion from StringBuilder // object to String using ToString method String str1 = sbdr.ToString(); Console.Write("StringBuilder object to String: "); Console.WriteLine(str1); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。