![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
CompareTo() method in C#
To compare two values, use the CompareTo() method.
The following are the return values −
- 0 = both the numbers are equal
- 1 = second number is smaller
- -1 = first number is smaller
Here is the code to implement CompareTo() method in C# −
Example
using System; public class Demo { public static void Main() { int val1 = 100; int val2 = 100; int res = val1.CompareTo(val2); Console.WriteLine(res); } }
Output
0
Advertisements