substring - Weird behavior with indexof method in c# -


i have code, entities list <string> received parameter. tried cast entities[x] string in way possible, being string. checked entities[x] string returning true.

for(int x = 0; x < entities.count; x++) {     console.writeline(entities[x] + " " +  "a pencil g smartboard tabletc pencil ".indexof(entities[x])); } 

the result is:

pencil 30 smartboard 11 tabletc -1 

why indexof returns -1 "tabletc"?

the string input begins backspace character, ascii 8.

try like

"... \btabletc ...".indexof(entities[2]) 

where \b means backspace character.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -