
- 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# Linq Select Method
Use the Select method to modify the elements in an array.
The following is our string array.
string[] stationery = { "diary", "board", "pencil", "whiteboard" };
The Select method also specifies Lambda Expressions as shown below −
Example
using System; using System.Linq; using System.Collections.Generic; public class Demo { public static void Main() { string[] stationery = { "diary", "board", "pencil", "whiteboard" }; var res = stationery.AsQueryable().Select((item, index) => new { result = item.Substring(0, index + 4) }); foreach (var str in res) { Console.WriteLine("{0}", str); } } }
Output
{ result = diar } { result = board } { result = pencil } { result = whitebo }
- Related Articles
- C# Linq Where Method
- C# Linq Intersect Method
- C# Linq FirstorDefault Method
- C# Linq Reverse Method
- C# Linq SelectMany Method
- C# Linq Skip() Method
- C# Linq SkipLast Method
- C# Linq Sum() Method
- C# Linq TakeWhile() Method
- C# Linq ThenBy Method
- C# Linq LastorDefault Method
- C# Linq Zip Method
- C# Linq Contains Method
- C# Linq Count method
- C# Linq Except Method

Advertisements