string.EndsWith works differently? What am I missing? #93961
-
In real life I have an asp.net core web application with Blazor server components running .net 7 (windows) (A). Calls are made to another class library (.net 7 windows) (B) which in turn makes calls to a class library (.net framework 4.8) (C).
string is being passed down the road. Finally B makes a call to a static method in C passing a parameter string bar.
when I pass in the string "abc" making the call from B (.net 7) to C (.net framework 4.8) the when I pass the string "abc" making the call from B (.net framwork 4.8) to C (.net framework 4.8) the Library C makes calls to e.g. XcvData which requires a null-terminated string. Code was failing on different locations while it turned out that trivial code string.EndsWidth didn't work. (Checked with In Visual Studio 2022 17.7.5 Pro x64 when I hover the parameter How is this string being passed/marshalled. When switching from .net 6 to .net 7 we started having exceptions, so I think something changed to strings or marshalling of strings? What am I missing here? Why does this happen? --> How do I properly check if string ends with '\0' when call from B (.net 7) to C (.net framwork 4.8) is made? attached sample solution (.zip file) ConsoleApp1.zip |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can use |
Beta Was this translation helpful? Give feedback.
#92025 (comment)
You can use
StringComparison.Ordinal
to change the behavior.