using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
// String containing uppercased words.
string sentence =
"Bob and Michelle are from Indiana.";
// Get all words.
string[] uppercaseWords = Regex.Split(sentence, @
"\W");
// Get all uppercased words.
var list = new List<string>();
foreach (string value in uppercaseWords)
{
// Check the word.
if (!string.IsNullOrEmpty(value) && char.IsUpper(value[0]))
{
list.Add(value);
}
}
// Write all proper nouns.
foreach (var value in list)
{
Console.WriteLine(value);
}
Bob
Michelle
Indiana