March 12, 2011

Separate ID's using comma then pass to database

This is simple console program which is used to built only for any sycnerio in which we have to bulk of ID's in string and pass that ID's into database by breaking each ID after comma.

Here's the code

static void Main(string[] args)
{
Console.WriteLine("Please enter name of friut by comma separated");

string data = Console.ReadLine();

string[] dataNos = data.Trim().Split(new char[] { ',' });
for (int i = 0; i < dataNos.Length; i++)
{
if (dataNos[i] != "")
{
string result = dataNos[i];
Console.WriteLine(result);
}
}

Console.ReadLine();
}

No comments:

Post a Comment