How can System.String be properly wrapped for case-insensitivy?

前端 未结 5 1725
谎友^
谎友^ 2021-01-12 07:05

This question is not about managing Windows pathnames; I used that only as a specific example of a case-insensitive string. (And I if I change the example now, a w

5条回答
  •  时光取名叫无心
    2021-01-12 07:31

    Hmm... I don't think string case is the only challenge you have. Let me ask you a couple of questions:

    Is c:\myPath the same as c:/myPath? How about file:////c:/myPath? Or how about \\myMachine\c$\myPath?

    I kind of understand where you are headed and what you want accomplished, but it just seems like you're tunnel-visioned on a simple problem - why build a framework that does what a simple .ToLower() vs ToLower() comparison does?

    That being said, if your problem scope, in addition to the string casing, involves trying to assess absolute equality of two given paths, it makes sense to write up a class. But that would require a lot more involved solution than what you are proposing...

提交回复
热议问题