![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
C# Queryable SequenceEqual() Method
To check whether two sequences are equal or not, use the SequenceEqual() method.
Firstly, set the sequences.
Employee emp1 = new Employee { EmployeeRank = 4, EmpName = "Amit", EmpMarks = 90 }; Employee emp2 = new Employee { EmployeeRank = 5, EmpName = "Raman", EmpMarks = 95 }; List<Employee> employee1 = new List<Employee> { emp1, emp2 }; List<Employee> employee2 = new List<Employee> { emp1, emp2 };
Now, find whether the sequences are equal or not.
employee1.AsQueryable().SequenceEqual(employee2);
Here is the example that shows the result.
Exmaple
using System; using System.Linq; using System.Collections.Generic; public class Demo { public static void Main() { Employee emp1 = new Employee { EmployeeRank = 4, EmpName = "Amit", EmpMarks = 90 }; Employee emp2 = new Employee { EmployeeRank = 5, EmpName = "Raman", EmpMarks = 95 }; List<Employee> employee1 = new List<Employee> { emp1, emp2 }; List<Employee> employee2 = new List<Employee> { emp1, emp2 }; bool res = employee1.AsQueryable().SequenceEqual(employee2); Console.WriteLine("Lists are equal? = "+res); } } public class Employee { public int EmployeeRank { get; set; } public string EmpName { get; set; } public int EmpMarks { get; set; } }
Output
Lists are equal? = True
Advertisements