Created
October 17, 2013 17:46
-
-
Save JamesBender/7029212 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace LinqLibrary | |
{ | |
public class LinqExample | |
{ | |
public int GetNumberOfWords() | |
{ | |
string sentence = @"The quick brown fox jumped over the lazy dog."; | |
IEnumerable<string> result = from text in sentence | |
let words = sentence.Split(new char[] { ' ' }) | |
from word in words | |
select word; | |
var numberOfWords = result.Count(); | |
return numberOfWords; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment