IsNullOrEmpty与IsNullOrWhiteSpace性能谁比较高呢?

在string都是空字符串的情况下:

IsNullOrWhiteSpace要比IsNullOrEmpty快大约 1~5倍左右

如果都是为null呢,谁比较快呢?

IsNullOrWhiteSpace稳定在3,而IsNullOrEmpty在1~12之间来回跳跃

如果有值呢,谁比较快?

IsNullOrWhiteSpace基本稳定在3左右,而IsNullOrEmpty跳动幅度比较大一些在3~50之间

测试代码如下:

如此看来IsNullOrWhiteSpace性能是要比IsNullOrEmpty高的多得多的。

但如果处理上万条,几十万条数据却是IsNullOrEmpty性能要高的。但是IsNullOrWhiteSpace相对比较稳定,IsNullOrEmpty跳动幅度比较大一些

IsNullOrEmpty与IsNullOrWhiteSpace性能比较的更多相关文章

  1. IsNullOrEmpty与IsNullOrWhiteSpace区别

    IsNullOrEmpty public static bool IsNullOrEmpty(String value) { return (value == null || value.Length ...

  2. 【源码分析】你必须知道的string.IsNullOrEmpty && string.IsNullOrWhiteSpace

    写在前面 之前自信撸码时踩了一次小坑,代码如下: private static void AppServer_NewMessageReceived(WebSocketSession session, ...

  3. IsNullOrEmpty和IsNullOrWhiteSpace的区别

    IsNullOrEmpty // string /// <summary>Indicates whether the specified string is null or an < ...

  4. C# IsNullOrEmpty与IsNullOrWhiteSpace

    IsNullOrEmpty:非空非NULL判断 IsNullOrWhiteSpace:非空非NULL非空格判断 后者优于前者 if (!string.IsNullOrWhiteSpace(valueE ...

  5. C#空值和null判断

    一.空值判断效率 string s = ""; if(s == ""){} if(s == string.Empty){} if (string.IsNullO ...

  6. c#常用方法和类

    1.  数据类型转换函数 Convert.ToXXX(); XXX.Parse(); XXX.TryParse(); 2. 日期相关的类与函数 获取系统当前日期(含时间):DateTime.Now 获 ...

  7. csharp: Setting the value of properties reflection

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  8. string类(二、常用string函数)

    常用string相关,参至System.String类: 1/ string.Length a.Length字符串长度 string a="a5"; //a.Length==2 s ...

  9. 判断字符串为空 为null

    str:string; delphi str.IsNullOrEmpty str.IsNullOrWhiteSpace TStringHelper for delphi only,c++ no use ...

随机推荐

  1. (三十四)NavigationController初步

    为了了解底层,首先不基于UIWindow而基于UIWindow来创建App. 由于Xcode6没有以前的基于UIWindow的空项目,所以选择SingleView,然后删除storyboard,移除B ...

  2. 《java入门第一季》之类(Scanner类)

    /* * Scanner:用于接收键盘录入数据. * * 前面的时候: * A:导包 * B:创建对象 * C:调用方法 * * System类下有一个静态的字段: * public static f ...

  3. Linux管道编程实例

    /*管道 可以把管道想象为两个实体之间的单向连接器.注意,管道是半双工的, 如果需要全双工通讯,应该转而考虑套接字. 匿名管道又称管道,提供了一个进程与它的兄弟进程通讯的方法,只存在于父进程中: 命名 ...

  4. 给Cocos2D视图添加手势支持

    见如下代码: UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc]initWithTarget:self ac ...

  5. python标准库:collections和heapq模块

    http://blog.csdn.net/pipisorry/article/details/46947833 python额外的数据类型.collections模块和heapq模块的主要内容. 集合 ...

  6. Leetcode_80_Remove Duplicates from Sorted Array II

    本文是在学习中的总结,欢迎转载但请注明出处:http://blog.csdn.net/pistolove/article/details/43835055 Follow up for "Re ...

  7. 优雅的App完全退出方案(没有任何内存泄漏隐患)

    在Android开发过程中,特别是界面比较多的情况下,用平常的退出方式往往是不能完全退出这个应用,网络上也好多各种退出方案.其中一种应该是被广大开发者采纳使用,也非常的清晰方便,就是在Applicat ...

  8. Memcached学习笔记 — 第四部分:Memcached Java 客户端-gwhalin(1)-介绍及使用

     介绍 Memcached java client是官方推荐的最早的memcached java客户端.最新版本:java_memcached-release_2.6.1. 官方下载地址:http ...

  9. 网站开发进阶(四)Tomcat Server处理一个http请求的过程

    Tomcat Server处理一个http请求的过程 假设来自客户的请求为: http://localhost:8080/wsota/wsota_index.jsp 1) 请求被发送到本机端口8080 ...

  10. Android下Json数据解析

    如从网络获取JSON 则需要创建一个工具类,该类返回一个字符串为JSON文本 package com.example.jsonapp; import java.io.InputStreamReader ...