'; var adpushup = adpushup || {}; adpushup.que = adpushup.que || []; adpushup.que.push(function() { adpushup.triggerAd(ad_id); });
The Equality Operator ( ==) is the comparison operator and the Equals() method in C# is used to compare the content of a string.
The Equals() method compares only content.
Example
using System;namespace ComparisionExample { class Program { static void Main(string[] args) { string str = "hello"; string str2 = str; Console.WriteLine("Using Equality operator: {0}", str == str2); Console.WriteLine("Using equals() method: {0}", str.Equals(str2)); Console.ReadKey(); } }}
Output
Using Equality operator: TrueUsing equals() method: True
The Equality operator is used to compare the reference identity.
Let us see another example.
Example
using System;namespace Demo { class Program { static void Main(string[] args) { object str = "hello"; char[] values = {'h','e','l','l','o'}; object str2 = new string(values); Console.WriteLine("Using Equality operator: {0}", str == str2); Console.WriteLine("Using equals() method: {0}", str.Equals(str2)); Console.ReadKey(); } }}
Output
Using Equality operator: FalseUsing equals() method: True
Updated on: 23-Jun-2020
6K+ Views
Related Articles
- Difference between == and equals() method in Java.
- What is the difference between equals() method and == operator in java?
- C# Enum Equals Method
- Difference between Method Overriding and Method Hiding in C#
- Equals(String, String) Method in C#
- Difference between Method and Function in C#
- Difference between equals() vs equalsIgnoreCase() in Java
- What is the difference between equals and compareTo in Java?
- UInt16.Equals Method in C# with Examples
- UInt32.Equals() Method in C# with Examples
- UInt64.Equals Method in C# with Examples
- Int16.Equals Method in C# with Examples
- Int32. Equals Method in C# with Examples
- Int64.Equals Method in C# with Examples
- AngularJS – equals() method
Advertisem*nts
';adpushup.triggerAd(ad_id); });