this is a sample about split method and join method about string class.
any comments or advice are appreciated.
namespace SplitAndJoinAboutString
{
class Program
{
static void Main(string[] args)
{
string data = "name,age,gender,phone number,address,mail";
string[] sdata;
char[] delimiter = new char[] { ','};
sdata = data.Split(delimiter, data.Length);
foreach (string word in sdata)
{
Console.WriteLine(word);
}
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~");
string joined;
joined = String.Join(",",sdata);//split string with char type variable, but join with string type
Console.WriteLine(joined);
}
}
}
Subscribe to:
Post Comments (Atom)


No comments:
Post a Comment