Home > Back-end >  string IndexOf EOT does not work in net-5 projects
string IndexOf EOT does not work in net-5 projects

Time:12-28

I am upgrading one of the net framework project to net5, observed a change in behavior of a same line of code in net framework vs net5. For example if I have a text wit EOT, net5 doesn't give the index but the same works in net framework project.

string sampleString = "hello"   "\u0004"   "test";
string delimiter = "\u0004";
var test = sampleString.IndexOf(delimiter);
\\Net framework gives a index **5**
\\Net core gives a index **0** for the code

Any reason for this change in behavior?

CodePudding user response:

try this

string delimiter = "\u0004";
string sampleString = "hello"   delimiter   "test";

var uniCodeValue = char.Parse(delimiter);//  '\u0004' unicode values
var test = sampleString.IndexOf(uniCodeValue); //5
test = sampleString.IndexOf("test"); //6
  • Related