- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Int16.Equals Method in C# with Examples
The Int16.Equals() method in C# is used to return a value indicating whether this instance is equal to a specified object or Int16.
Syntax
Following is the syntax −
public bool Equals (short ob); public override bool Equals (object ob);
Above, the parameter ob for the 1st syntax is an Int16 value to compare to this instance.
The parameter ob for the 2nd syntax is the object to compare to this instance.
Example
Let us now see an example to implement the Int16.Equals() method −
using System; public class Demo { public static void Main(){ short val1 = 15; short val2 = 17; Console.WriteLine("Are they equal? = "+(val1.Equals(val2))); } }
Output
This will produce the following output −
Are they equal? = False
Example
Let us now see another example to implement the Int16.Equals() method −
using System; public class Demo { public static void Main(){ short val1 = 25; short val2 = 25; Console.WriteLine("Value1 = "+val1); Console.WriteLine("Value2 = "+val2); Console.WriteLine("Are they equal? = "+(val1.Equals(val2))); } }
Output
This will produce the following output −
Value1 = 25 Value2 = 25 Are they equal? = True
Advertisements