Hey everyone. In stumped. How would you take a string and verfiy it is a word?

Example:

String a = sldkjf
String b = dog

The results should be, "dog" is a word and "sldkjf" is not.

Any direction would be greatly appreciated.

Question 1: How do you know "dog" is a word?

Question 2: If you didn't know if "dog" was a word or not, how would you find out?

you could get a text file with a lot of words in it and then check for a specific word

System.IO.StreamReader reader = new System.IO.StreamReader("FILEPATH");
String text = reader.ReadToEnd();
if (System.Text.RegularExpressions.Regex.IsMatch(text, textBox1.Text))
    {
        BLABLA
    }
    else
        BLABLA
commented: Helpful first post. +7

"Question 2: If you didn't know if "dog" was a word or not, how would you find out?"

I would look it up in a dictionary. Is there a C# class like a dictionary? Or is there another way I am missing?

Ohhhh. I see. Thank you Alejo.Book!

Yes. You need to have an "electronic" version of a dictionary that contains valid words. This electronic version can be a text file. Additionally, new words are added to dictionaries from time to time, so you may need to update your file from time to time.

Do you want to write this with nested loops, or will a canned solution using regular expressions do?

Here's the regex version:
// At the top of your source:
using System.Text.RegularExpressions;