首页 > 编程语言 >c# 判断字符串是否为空的效率问题

c# 判断字符串是否为空的效率问题

时间:2023-03-02 20:46:04浏览次数:36  
标签:... string 效率高 c# continue 为空 字符串 IsNullOrEmpty

循环1000000000次,

string a = "100";
string b = "200";

for (int i = 0; i < 1000000000; i++)

            {

                if(string.IsNullOrEmpty(a))

                {

                    continue;

                }

 

                if (string.IsNullOrEmpty(b) )

                {

                    continue;

                }

            }

 

string.IsNullOrEmpty(a)比a=string.Empty()效率高

a=string.Empty()跟a="" 效率一样

if(a){...}  if(b){...}  比 if(a || b效率高)

 

if(a && b) 比  if(a){...}  if(b){...}   效率高

 

标签:...,string,效率高,c#,continue,为空,字符串,IsNullOrEmpty
From: https://www.cnblogs.com/simpleyue/p/17173385.html

相关文章

  • joi2023 C
    考虑正解:这么一个流程,我们怎么实现能够不退化地完成这个01-BFS呢?先看代码:#include<bits/stdc++.h>usingnamespacestd;#defineintlonglong#definef(i,a,b)......
  • 在Anaconda虚拟环境中安装jupyternotebook
    使用condaenvlist命令查看已有的虚拟环境(首次只有base)使用condacreate-nyour_env_namepython=x.x创建虚拟环境使用condaactivateyour_env_name进入新创建的虚拟......
  • vue-cli
    Vue-clivue-cli创建项目1.下载node解释器在node官网中下载node解释器,安装时一直下一步就行2.验证node下载完是自动添加环境变量的,可以在cmd中输入node来验证......
  • DVWA CRSF
    主要方式就是引诱用户去点击一个是黑客精心构造的一个html中的一个按钮(或者是引诱用户去访问一个精心构造的url),而该按钮会发生一个请求给目标服务器<html><ahref="h......
  • 每日一道思维题——1725H - Hot Black Hot White
    题意:给定n个整数Ai,定义一种运算concat(Ai,Aj)讲AiAj拼接在一起如concat(12,34)=1234若i,j上颜色不同有运算concat(Ai,Aj)×concat(Aj,Ai)+Ai×Aj≡Zmod3思路:  代码:......
  • Diffusion-LM Improves Controllable Text Generation
    目录概符号说明流程代码LiX.L.,ThickstunJ.,GulrajaniI.,LiangP.andHashimotoT.B.Diffusion-lmimprovescontrollabletextgeneration.arXivpreprinta......
  • Codeforces Round #850 (Div. 2, based on VK Cup 2022 - Final Round)
    Preface补题,之前由于要准备开学考(其实只是临时抱佛脚罢了),所以好久没写题不过索性学校题目简单,微积分线代C程都满绩了(甚至溢出好多),思政被卡了一分满绩点,而大英不出所料3.7......
  • 软件体系架构方面英文文章翻译----Android中MVC、MVP和MVVM架构模式的区别
    DifferenceBetweenMVC,MVPandMVVMArchitecturePatterninAndroid22Dec,2022Developinganandroidapplicationbyapplyingasoftwarearchitecturepattern......
  • nvalid bound statement (not found): com.ruoyi.xxx.mapper.xxx
    出现这个问题是由于resource目录下的mapper命名空间和java目录下的mapper不对应,踩坑点是在Java目录创建多层目录时都是用点号.分隔目录,所以在resource目录创建多层目录也用......
  • IDEA - Code format
    1.OpenIDEA>File>Settings>  SetTabandIndent Sethardwrap2.Chooseyour.pyfile>ReformatCode  ......