Mid From PDF Coding Scenarios C# Coding Interview

Count occurrence of each word?

string sentence = "dotnet is great dotnet is powerful";
string[] words = sentence.Split(' ');
Dictionary<string, int> map = new Dictionary<string, int>();
foreach (string word in words)
map[word] = map.ContainsKey(word) ? map[word] + 1 : 1;

More from C# Programming Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details