String Manipulation Question
I am new to C# programming and I would like to ask for opinions on some coding procedures. :)
I have a user input sentence that goes into â strValue â, from there it gets cut into separate words.
I then need to add the first letter and âayâ to the end of the word. (So that it forms a pig Latin style word.)Then I need to restring them back into the same order that they were originally.
I think I'm putting them into an array, and if so there is going to be no problem getting them back.
What I would like to know is âWould I be better off to place the string manipulations into separate constructors, methods, or maybe lumping them all together in either oneâ.
I know that each person does it differently, but I would like some feedback on what may be a better way to do this. Thank you.
private string strValue = " ";
private string s = " ";
//Cuts string into seperate words (char ?)
char[] separator = { ' ' };
separator = { ' ' };
string[] s;
s = strValue.Split(separator);
foreach (string word in s)
{
Console.Write("{0}" + " ", word);
}
s = strValue.Insert();
//add first letter to end of word
s = strValue.Insert();
//add "ay" to end of word
s = strValue.Remove(0, 1);
//Remove first letter
|