Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

string IndexOf EOT does not work in net-5 projects

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading