我在.NET 3.5下使用TrimEnd()得到不一致的结果。 TrimEnd似乎很简单易用,是有什么我做错了或这是一个错误“TrimEnd()”的意外结果...结果是随机过于贪婪的
成功案例
var foundvalue = "hosted.local.chatter.com";
Console.WriteLine(foundvalue.TrimEnd(".chatter.com".ToCharArray()));
// Result is "hosted.local" which is expected.
失败案例
var foundvalue = "hosted.local.chattermailcom";
Console.WriteLine(foundvalue.TrimEnd(".chattermailcom".ToCharArray()));
// Result is "hosted" which is incorrect
哇...零upvotes。我猜除了我,每个人都知道这个!这是当你自学成才时会发生什么(对S.O.有很多阅读) – LamonteCristo