Skip to content

Instantly share code, notes, and snippets.

@bobixaka
Created August 28, 2013 21:24
Show Gist options
  • Save bobixaka/6371503 to your computer and use it in GitHub Desktop.
Save bobixaka/6371503 to your computer and use it in GitHub Desktop.
Dictionary
using System;
using System.Collections.Generic;
using System.Text;
namespace Task_14_Dictionary
{
class Dictionary
{
static void Main()
{
Console.Write("Enter a word: ");
string Word = Console.ReadLine();
string WordFromDictionary = "";
string Explanation = "";
bool WordFound = false;
List<string> Dictionary = new List<string>();
Dictionary.Add(".NET – platform for applications from Microsoft");
Dictionary.Add("CLR – managed execution environment for .NET");
Dictionary.Add("namespace – hierarchical organization of classes");
Dictionary.Add("length - the longest extent of anything as measured from end to end");
Dictionary.Add("cat - a small domesticated carnivore");
Dictionary.Add("chair - a seat, especially for one person, usually having four legs for support and a rest for the back.");
Dictionary.Add("advertisement - a paid announcement, as of goods for sale, in newspapers or magazines, on radio or television, etc.");
Dictionary.Add("stupid - lacking ordinary quickness and keenness of mind; dull.");
for (int i = 0; i < Dictionary.Count; i++)
{
for (int p = 0; p < Dictionary[i].Length; p++)
{
while (p < Dictionary[i].Length && Dictionary[i][p] != ' ' && Dictionary[i][p] != '-')
{
WordFromDictionary += Dictionary[i][p];
p++;
}
p += 3;
while (p < Dictionary[i].Length)
{
Explanation += Dictionary[i][p];
p++;
}
}
if (String.Compare(Word,WordFromDictionary, true) == 0)
{
Console.WriteLine();
Console.WriteLine("{0} is {1}", Word, Explanation);
Console.WriteLine();
WordFound = true;
break;
}
WordFromDictionary = "";
Explanation = "";
}
if (WordFound == false)
{
Console.WriteLine("\nWord not found in the dictionary!\n");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment