c# - String from excel having length size different than real value -


i built web-app reading string value uploaded excel file row row using epplus.

just encountered strange behaviour, string.length size different it's real value.

code make clear :

//pretend str value = "cat" string str = worksheets.cells["a1"].value.tostring().trim();  //output = "cat" debug.writeline(str);  //it should = 3 right //but it's = 4 debug.writeline(str.length); 

can explain why can happen ? , how solve it, because need compare string own hardcoded string

if length reporting 4 there's else in string. have taken @ byte-by-byte?

try this:

var cat = worksheets.cells["a1"].value.tostring().trim(); foreach (var c in cat.tochararray()) {     debug.writeline("{0}: '{1}'", (int)c, c); } 

it should determine else hidden in string. doubt "odd" epplus doing (i use time , have never experienced this) - it's strange in source data.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -