Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 10th, 2007, 11:38 AM
Registered User
 
Join Date: Apr 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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






Similar Threads
Thread Thread Starter Forum Replies Last Post
String manipulation Franco1 Visual Basic 2005 Basics 1 July 16th, 2008 12:53 PM
String manipulation pcase XSLT 5 June 14th, 2007 10:32 AM
String manipulation YoungLuke C# 4 May 4th, 2007 01:46 AM
String Manipulation twsinc Access 3 February 23rd, 2004 09:57 AM
String Manipulation Ben Access VBA 2 July 8th, 2003 05:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.