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
Post a Comment