
Newbie question about arrays
Quote:
> my array? For example, if the user inputs "What kind of question?", I
> need to find out what the punctuation is that ends the sentence(the last
> element) and return that character to a variable.
Your code splits the string on a space, so the punctuation will most likely
be with the last word. Given your original example ("What kind of
question?"), and given your code:
Quote:
> string sentence = Console.ReadLine();
> string[] sentenceArray = sentence.Split(" ".ToCharArray());
I'm assuming that sentenceArray[] will contain the following:
sentenceArray[0] = "What"
sentenceArray[1] = "kind"
sentenceArray[2] = "of"
sentenceArray[3] = "question?"
You'll have to check the last character in the last array element to find
out about punctuation.
--
Jeff Ferguson
http://staff.magenic.com/jefff/