SUN SUN - 3 months ago 17
ASP.NET (C#) Question

remove value from after space detects

I just want to remove values from string after space

Example

if string value is (Music powerbanks pendrives) then it should replace it with (Music)

string productCategory = "Music PowerBank pendrives";


I just want to get first word from string

Answer
int index = productCategory.IndexOf(' ');
if (index != -1)
    productCategory = productCategory.Substring(0, index);
Comments