Why is String.IsNullOrEmpty faster than String.Length?

前端 未结 7 2061
心在旅途
心在旅途 2020-12-14 17:28

ILSpy shows that String.IsNullOrEmpty is implemented in terms of String.Length. But then why is String.IsNullOrEmpty(s) faster than

7条回答
  •  我在风中等你
    2020-12-14 17:46

    it may be caused by the types of the involved variables. *Empty seems to use a boolean, length an int (i guess).

    Peace !

    • : edit

提交回复
热议问题