﻿ C# Sharp Exercises: LINQ : Find the strings for a specific minimum length - w3resource

# C# Sharp Exercises: LINQ : Find the strings for a specific minimum length

## C# Sharp LINQ : Exercise-22 with Solution

Write a program in C# Sharp to find the strings for a specific minimum length.

Sample Solution:-

C# Sharp Code:

``````using System;
using System.Collections.Generic;
using System.Linq;

class  LinqExercise22
{
static void Main(string[] args)
{
string[] arr1;
int n,i,ctr;

Console.Write("\nLINQ : Find the strings for a specific minimum length : ");
Console.Write("\n------------------------------------------------------\n");

Console.Write("Input number of strings to  store in the array :");
arr1 =new string[n];
Console.Write("\nInput {0} strings for the array  :\n",n);
for(i=0;i<n;i++)
{
Console.Write("Element[{0}] : ",i);
}

Console.Write("\nInput the minimum length of the item you want to find : ");

IEnumerable<string> objNew = from m in arr1
where m.Length >= ctr
orderby m
select m;
Console.Write("\nThe items of minimum {0} characters are : \n",ctr);
foreach (string z in objNew)
Console.WriteLine("Item: {0}", z);

}
}
```
```

Sample Output:

```LINQ : Find the strings for a specific minimum length :
------------------------------------------------------
Input number of strings to  store in the array :3
Input 3 strings for the array  :
Element[0] : Welcome
Element[1] : to
Element[2] : W3resource

Input the minimum length of the item you want to find : 10

The items of minimum 10 characters are :
Item: W3resource
```

Flowchart:

C# Sharp Code Editor: