
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Check If Two StringBuilder Objects Are Equal in C#
To check if two StringBuilder objects are equal, the code is as follows −
Example
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)); } }
Output
This will produce the following output −
Is StringBuilder3 equal to StringBuilder2? = True
Example
Let us see another example −
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)); } }
Output
This will produce the following output −
Is StringBuilder1 equal to StringBuilder2? = True
Advertisements