Remove comma from string

To remove comma from string….

private string RemoveComma(string InputStr)
{

string strret = InputStr;
if (InputStr.Length – 1 == InputStr.LastIndexOf(“,”))
{
strret = InputStr.Substring(0, InputStr.Length – 1);
}
if (0 == InputStr.IndexOf(“,”))
{
strret = strret.Substring(1, strret.Length – 1);
}
return strret;

}

Happy Coding….!!! 🙂

Advertisements

Create comma separated string

To Create comma separated string…..

Declare 3 variable  called min, max, and intString to hold value. [you can use string also]

int max = 10;
int min = 1;
int intString = “”;

for (int icnt = min; icnt <= max; icnt++)
{

if intString == “”)
{
intString = Convert.ToString(icnt);
}
else
{
intString = Convert.ToString(intString) + “,” + Convert.ToString(icnt);
}

}

 

Happy Coding…!!! 🙂