- 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
SByte.Equals() Method in C# with Examples
The SByte.Equals() method in C# is used to return a value indicating whether this instance is equal to a specified object or SByte.
Syntax
The syntax is as follows −
public bool Equals (sbyte ob); public override bool Equals (object ob);
Above, the ob parameter for an SByte value to compare to this instance, whereas the ob parameter for the 2nd syntax is an object to compare with this instance.
Example
Let us now see an example −
using System; public class Demo { public static void Main() { sbyte s1 = 10; sbyte s2 = 100; Console.WriteLine("Value of S1 = "+s1); Console.WriteLine("Value of S2 = "+s2); Console.WriteLine("Is s1 and s2 equal? = "+s1.Equals(s2)); int res = s1.CompareTo(s2); if (res > 0) Console.WriteLine("s1 > s2"); else if (res < 0) Console.WriteLine("s1 < s2"); else Console.WriteLine("s1 = s2"); } }
Output
This will produce the following output −
Value of S1 = 10 Value of S2 = 100 Is s1 and s2 equal? = False s1 < s2
Example
Let us now see another example −
using System; public class Demo { public static void Main() { sbyte s1 = 10; object s2 = 10; Console.WriteLine("Value of S1 = "+s1); Console.WriteLine("Value of S2 = "+s2); Console.WriteLine("Is s1 and s2 equal? = "+s1.Equals(s2)); } }
Output
This will produce the following output −
Value of S1 = 10 Value of S2 = 10 Is s1 and s2 equal? = False
Advertisements