Count of characters
#1

i am trying to execute a db update but when i try it, i get an error because name looks like this

 

Manual for making Heros necklace

so the problem is that appear so much . then i have coded this to execute command:

 

 

if (items.description.Contains(" "))
                    {
                        sb.Append(items[i].description);[/i]
[i]                        indice = items[/i][i][i].description.IndexOf(" ");[/i][/i]
[i][i]                        sb.Insert(indice, \\);[/i][/i]
[i][i]                        items[/i][/i][i][i][i].description = sb.ToString();[/i][/i][/i]
[i][i][i]                    }  [/i][/i][/i]
[i][i][i]                    record = ...[/i][/i][/i]

[i][i][i]and this looks like this:[/i][/i][/i]

[i][i][i] [/i][/i][/i]

[i][i][i]Manual for making Hero\s necklace[/i][/i][/i]

[i][i][i]so that is what i wanted but when name has more than one i still have problems, so i would like you help me knowing how to code this to test how much are there and then, inset a \ before all .[/i][/i][/i]

[i][i][i] [/i][/i][/i]

[i][i][i]thanks in advance.[/i][/i][/i]

#2

Try to use replace instead:

if (items[i].description.Contains("")){
items[i].description = items[i].description.Replace("", @"\");
}

Or you could simply put this(without checking if contains, because if there are none it will put none):

items[i].description = items[i].description.Replace("", @"\");

#3

it works perfectly someone.

 

thanks so much Smile

#4

Mark the topics tag as SOLVED if the issue is solved.

Thanks

#5


Mark the topics tag as SOLVED if the issue is solved.

Thanks

 

sorry, i forgot to do it.

 

thanks.

#6
Thank you



Forum Jump:


Users browsing this thread: 1 Guest(s)