473,508 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SelectMany second parameter problem

Say I have an array of poems and I want to get all words in these poems.

Expand|Select|Wrap|Line Numbers
  1. string[] poems = { "Birds are singing.", "Ducks are playing." };
  2. var voc = poems.SelectMany
  3. (poem =poem.Split(' ', '.'), (word) =word.Length 0)
  4.  
In the second lambda parameter I want to exclude those empty strings
created by the first lambda Split expression. But the compiler thinks
the second parameter is not of correct type.

How can I write the second lambda expression?
Jun 27 '08 #1
1 1430
You just need to apply a "where" to the selection, as below (only the
first bit is needed - the rest is just to demo)

string[] poems = { "Birds are singing.", "Ducks are
playing." };
var voc = poems.SelectMany(
poem =poem.Split(' ', '.')
.Where(word =word.Length 0));

foreach(var word in from word in voc
group word by word into agg
orderby agg.Key
select agg)
{
System.Console.WriteLine("{0}: {1}",
word.Key, word.Count());
}

Marc
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3818
by: Dan | last post by:
I've run into an interesting problem, and seemed to have stumped 3 newsgroups and 2 other forums. For some reason when I try to insert a record into a SQL table that has a Text column, the...
4
3448
by: Pujo Aji | last post by:
Hello, I would like to read file during runtime(the other third party vendor write the program and my program read it every second). I can't do it until the third party vendor stop writing it....
15
10053
by: H00ner | last post by:
Hello All Hope you can help Been pulling my hair out about a popup problem in ASP.NET. One of the forms i wrote requires the user to select a product from a list in a popup web form. the...
2
4575
by: John Howard | last post by:
I am invoking a second form and would like to pass a parameter. My code is: Private Sub btnHelp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHelp.Click Dim...
1
1479
by: ABC | last post by:
When the first web page loading, it is normal, ok no problem. When second loading web page without closed IE, it cannot raise Page_Load event, how to fix this problem?
1
1834
by: wolfing1 | last post by:
I read somewhere that server.transfer had a 2nd parameter so control and input values were 'passed' to the transferred to page, but it's giving me an error of wrong number of parameters. I have...
4
782
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I make a 10 second delay? ----------------------------------------------------------------------- There...
28
2631
by: galathaea | last post by:
On Mar 2, 11:29 pm, galath...@veawb.coop (galathaea) wrote: still being very naive about this whole crackpot / crank thing i accidentally let the engineer inside think too hard about this ...
4
4560
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.