-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
35 lines (25 loc) · 1.09 KB
/
Program.cs
File metadata and controls
35 lines (25 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
string[] myStrings = new string[2] { "I like pizza. I like roast chicken. I like salad", "I like all three of the menu choices" };
int stringsCount = myStrings.Length;
string myString = "";
int periodLocation = 0;
for (int i = 0; i < stringsCount; i++)
{
myString = myStrings[i];
periodLocation = myString.IndexOf(".");
string mySentence;
// extract sentences from each string and display them one at a time
while (periodLocation != -1)
{
// first sentence is the string value to the left of the period location
mySentence = myString.Remove(periodLocation);
// the remainder of myString is the string value to the right of the location
myString = myString.Substring(periodLocation + 1);
// remove any leading white-space from myString
myString = myString.TrimStart();
// update the comma location and increment the counter
periodLocation = myString.IndexOf(".");
Console.WriteLine(mySentence);
}
mySentence = myString.Trim();
Console.WriteLine(mySentence);
}