String comparison performance in C#

后端 未结 10 1648
一向
一向 2020-12-20 11:42

There are a number of ways to compare strings. Are there performance gains by doing one way over another?

I\'ve always opted to compare strings like so:



        
10条回答
  •  青春惊慌失措
    2020-12-20 12:08

    Here is the most complete and helpful MSDN guide for string comparison I have found.

    Use comparisons with StringComparison.Ordinal or StringComparison.OrdinalIgnoreCase for better performance.

提交回复
热议问题