
- 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# into keyword
Set query in a select clause using the into operator.
The following is our list with Employee details −
IList<Employee> employee = new List<Employee>() { new Employee() { EmpID = 1, EmpName = "Tom", EmpMarks = 90, Rank = 8} , new Employee() { EmpID = 2, EmpName = "Anne", EmpMarks = 60, Rank = 21 } , new Employee() { EmpID = 3, EmpName = "Jack", EmpMarks = 76, Rank = 18 } , new Employee() { EmpID = 4, EmpName = "Amy" , EmpMarks = 67, Rank = 20} , };
Now, fetch employee name that ends with k and rank is <20 and >5 using into operator.
var res = from e in employee where e.Rank > 5 where e.Rank < 20 select e into name where name.EmpName.EndsWith("k") select name;
Let us see the complete code.
Example
using System; using System.Linq; using System.Collections.Generic; public class Demo { public static void Main() { IList<Employee> employee = new List<Employee>() { new Employee() { EmpID = 1, EmpName = "Tom", EmpMarks = 90, Rank = 8} , new Employee() { EmpID = 2, EmpName = "Anne", EmpMarks = 60, Rank = 21 } , new Employee() { EmpID = 3, EmpName = "Jack", EmpMarks = 76, Rank = 18 } , new Employee() { EmpID = 4, EmpName = "Amy" , EmpMarks = 67, Rank = 20} , }; // fetching employee name that ends with k and rank is <20 and >5 var res = from e in employee where e.Rank > 5 where e.Rank < 20 select e into name where name.EmpName.EndsWith("k") select name; foreach (var emp in res) { Console.WriteLine("Name: "+emp.EmpName); Console.WriteLine("Marks: "+emp.EmpMarks); } } } public class Employee { public int EmpID { get; set; } public string EmpName { get; set; } public int EmpMarks { get; set; } public int Rank { get; set; } }
Output
Name: Jack Marks: 76
- Related Articles
- C# orderby Keyword
- C++ mutable keyword?
- ‘this’ keyword in C#
- abstract keyword in C#
- static keyword in C#
- volatile keyword in C#
- Final keyword in C#
- try keyword in C#
- return keyword in C#
- Static Keyword in C++
- “extern” keyword in C
- “register” keyword in C
- override Keyword in C++
- Restrict keyword in C
- Mutable keyword in C++?

Advertisements