
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
C# Program to return the difference between two sequences
Set two sequences.
double[] arr1 = { 10.2, 15.6, 23.3, 30.5, 50.2 }; double[] arr2 = { 15.6, 30.5, 50.2 };
To get the difference between both the above arrays, use Except() method.
IEnumerable<double> res = arr1.AsQueryable().Except(arr2);
The following is the complete code.
Example
using System; using System.Linq; using System.Collections.Generic; class Demo { static void Main() { double[] arr1 = { 10.2, 15.6, 23.3, 30.5, 50.2 }; double[] arr2 = { 15.6, 30.5, 50.2 }; Console.WriteLine("Initial List..."); foreach(double ele in arr1) { Console.WriteLine(ele); } IEnumerable<double> res = arr1.AsQueryable().Except(arr2); Console.WriteLine("New List..."); foreach (double a in res) { Console.WriteLine(a); } } }
Output
Initial List... 10.2 15.6 23.3 30.5 50.2 New List... 10.2 23.3
- Related Articles
- Return the discrete linear convolution of two one-dimensional sequences in Python
- Return the discrete linear convolution of two one-dimensional sequences and return the middle values in Python
- C# Program to get the difference between two dates
- C# program to list the difference between two lists
- Python program to list the difference between two lists.
- Java Program to Calculate the difference between two sets
- Python program to find difference between two timestamps
- Golang program to calculate difference between two slices
- C Program to calculate the difference between two time periods
- Golang program to calculate the symmetric difference between two slices
- C# program to check whether two sequences are the same or not
- Return the discrete linear convolution of two one-dimensional sequences with mode in Python
- C# Program to determine the difference in hours between two dates
- C# Program to get the difference between two dates in seconds
- C++ Program to Calculate Difference Between Two Time Period

Advertisements