Query by string length with Linq : where « LINQ « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / CSharp Tutorial » LINQ » where 
22.9.20.Query by string length with Linq
using System;
  using System.Linq;

  class Program
  {
      static void Main(string[] args)
      {
          string[] colors = {"Red""Orange""Yellow""Green"};
          var colorQuery = from color in colors
                           where color.Length <= 5
                           orderby color
                           select color;

          foreach (string s in colorQuery)
              Console.WriteLine(s);

          Console.WriteLine("\nPress any key to continue.");
          
      }
  }
22.9.where
22.9.1.Where Prototype
22.9.2.To remove all vowels from a string.
22.9.3.A Query Using the Standard Dot Notation Syntax
22.9.4.Query Using the Query Expression Syntax
22.9.5.Query string value by String.StartsWith
22.9.6.Where clause with string method and return IEnumerable object
22.9.7.Query with an Exception
22.9.8.Use string method in where clause
22.9.9.where clause
22.9.10.Use where to filer object list
22.9.11.Use && in where clause
22.9.12.Filtered: prints the name of each element of an integer array that is less than 5
22.9.13.prints strings where each element has the second letter 'i'.
22.9.14.Two where clauses
22.9.15.Using where clause in a while loop
22.9.16.Assign the loop variable to another variable declared inside the statement block
22.9.17.Filter string by its length
22.9.18.Display Products With Unknown Price
22.9.19.Get upper case chars
22.9.20.Query by string length with Linq
22.9.21.Query for filtering numbers
22.9.22.Filter by Make and Speed
22.9.23.LINQ Method Syntax
22.9.24.Simple method based query
22.9.25.Search Customers by first name
22.9.26.LINQ query to get strings starting with s
22.9.27.Ice Creams with price less than 10
22.9.28.Use function in where clause
22.9.29.Modifying Where Behavior
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.