|
-
Aug 4th, 2005, 06:17 AM
#1
Thread Starter
Member
[RESOLVED] StringManipulation
Hi guys,
I just want to make sure that what I am doing here is correct. The following class splitting a string into two strings when it finds ",". It works fine but I am a bit worried of my code.
Can you guys please let me know is it correct way splitting the string or is there any easier way I can write. I appreciate your comments.
public class StringManipulation
{
//constructor
StringManipulation(string textValues)
{
this.textOne = this.GetTextOne(textValues);
this.textTwo = this.GetTextTwo(textValues);
}
//Methods
public string GetTextOne(string textValues)
{
string[] arInfo = new string[1000];
string info = textValues;
char[] splitter = {','};
arInfo = info.Split(splitter);
if(arInfo.Length > 0)
{
return arInfo[0].Trim();
}
else
{
return string.Empty;
}
}
public string GetTextTwo(string textValues)
{
string[] arInfo = new string[1000];
string info = textValues;
char[] splitter = {','};
arInfo = info.Split(splitter);
if(arInfo.Length > 1)
{
return arInfo[1].Trim();
}
else
{
return arInfo[0].Trim();
}
}
//propterties
public string TextOne
{
return this.textOne;
}
public string TextTwo
{
return this.textTwo
}
//Member variables
private string textOne;
private string textTwo;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|