Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@JamesBender
Created October 17, 2013 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesBender/7029212 to your computer and use it in GitHub Desktop.
Save JamesBender/7029212 to your computer and use it in GitHub Desktop.
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