473,663 Members | 2,738 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 1440
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.SelectMan y(
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
3826
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 returned autogenerated Identity is wrong (on the VB side). This only occurs if the length of the value inserted for the text column is >= 8002. I've included a simple example below.
4
3454
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. anyone can help? Sincerely Yours, Pujo -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
15
10089
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 popup has a DataGrid on it and the page.load function DataBinds as you'd expect. I have Code-Behind in C# to emit a call to a JavaScript function which
2
4588
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 frmAdminHelp As New frmAdminHelp frmAdminHelp.Show() End Sub
1
1488
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
1844
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 IIS5, is that the problem? or is it that it's an ASP page (not ASPX)
4
782
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I make a 10 second delay? ----------------------------------------------------------------------- There is no built-in way to pause execution in javascript such as a sleep function, but hosts usually provide a method of some form. Web browsers are designed for event driven programming and only provide the « setTimeout » and « setInterval »...
28
2649
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 since my degree is in physics simulations and my career is in programming and i happened to have a simulation generator i have been building i generated a simulation for a gas in a column with gravity
4
4576
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 reservation of available resources (laptops, beamers, etc). The MySql database queries are already in place, as is the ASP administration panel. The frontend that users will see however, still needs some work. I'm really close, but since I'm no...
0
8436
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8858
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8548
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7371
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4182
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
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 we have to send another system
2
2000
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.