यह जांचने के लिए कि क्या दो StringBuilder ऑब्जेक्ट समान हैं, कोड इस प्रकार है -
उदाहरण
using System; using System.Text; public class Demo { public static void Main(String[] args){ StringBuilder strBuilder1 = new StringBuilder("Tim"); StringBuilder strBuilder2 = new StringBuilder("Tom"); StringBuilder strBuilder3 = new StringBuilder(); strBuilder2 = strBuilder3; Console.WriteLine("Is StringBuilder3 equal to StringBuilder2? = "+strBuilder3.Equals(strBuilder2)); } }
आउटपुट
यह निम्नलिखित आउटपुट देगा -
Is StringBuilder3 equal to StringBuilder2? = True
उदाहरण
आइए एक और उदाहरण देखें -
using System; using System.Text; public class Demo { public static void Main(String[] args){ StringBuilder strBuilder1 = new StringBuilder("Jacob"); StringBuilder strBuilder2 = new StringBuilder("Jacob"); Console.WriteLine("Is StringBuilder1 equal to StringBuilder2? = "+strBuilder2.Equals(strBuilder1)); } }
आउटपुट
यह निम्नलिखित आउटपुट देगा -
Is StringBuilder1 equal to StringBuilder2? = True