带C#示例的String.Equality(==)运算符

C#String.Equality运算符 (C# String.Equality operator )

"==" is a String.Equality operator in C#, it is used to check whether two strings objects have the same values or not.

“ ==”是C#中的String.Equality运算符 ,用于检查两个字符串对象是否具有相同的值。

Syntax:

句法:

    public static bool operator == (string a, string b);

Parameter: It has two parameters both are strings to compare..

参数:它有两个参数都是要比较的字符串。

Return value: bool – it returns a Boolean value. If strings have the same value, it returns true, else it returns false.

返回值: bool-返回布尔值。 如果字符串具有相同的值,则返回true ,否则返回false 。

Example:

例:

    Input:
string str1 = "IncludeHelp";
string str2 = "IncludeHelp";
String.Equality:
str1 == str2;
Output:
true

C#使用String.Equality(==)运算符比较两个字符串的示例 (C# Example to compare two strings using String.Equality (==) operator )

using System;
using System.Text;
namespace Test
{
class Program
{
static void Main(string[] args)
{
string str1 = "IncludeHelp";
string str2 = "IncludeHelp";
//comparing strings
Console.WriteLine("str1==str2: " + (str1 == str2));
if (str1 == str2)
Console.WriteLine("str1 and str2 have the same values");
else
Console.WriteLine("str1 and str2 don't have the same values");
str1 = "Hello world";
str2 = "IncludeHelp";
//comparing strings
Console.WriteLine("str1==str2: " + (str1 == str2));
if (str1 == str2)
Console.WriteLine("str1 and str2 have the same values");
else
Console.WriteLine("str1 and str2 don't have the same values");
//hit ENTER to exit
Console.ReadLine();
}
}
}

Output

输出量

str1==str2: True
str1 and str2 have the same values
str1==str2: False
str1 and str2 don't have the same values

Reference: String.Equality(String, String) Operator

参考: String.Equality(String,String)运算符

翻译自: https://www.includehelp.com/dot-net/string-equality-operator-with-example-in-c-sharp.aspx

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/542205.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

jQuery 倒计时

function getSec(){//获取名称为remindataSec的ulobj document.getElementsByName("remindataSec");for(i0;i<obj.length;i){//循环得到每个毫秒数var intDiff $("#remindataTime"i"").text();var id "reminTime"i;//得到毫秒数…

Linux远程连接与sshd服务安全设定

1.远程连接&#xff1a; 首先设置ip&#xff1a; 设置好之后&#xff0c;先ping一下IP 看能不能通 ssh root172.25.13.103 ##表示的是&#xff1a;连接ip为172.25.13.103的root用户 2.系统控制命令 系统控制命令的查看相关参数如下表 systemctl服务控制命令systemctl stat…

rabbitmq 同步策略_RabbitMQ高可用方案总结

RabbitMQ的集群方案有以下几种&#xff1a;1.普通的集群exchange&#xff0c;buindling再所有的节点上都会保存一份&#xff0c;但是queue只会存储在其中的一个节点上&#xff0c;但是所有的节点都会存储一份queue的meta信息。因为这样有两个好处&#xff1a;1)存储空间。如果每…

一个简单的封ip规则

2019独角兽企业重金招聘Python工程师标准>>> 一个简单通过nginx日志封ip规则&#xff08;仅仅自己方便使用&#xff09; #!/bin/bash #Version:1.0 #Date:2016-08-09 #作用:防刷IP地址,解封蜘蛛,解封5天前封的IP地址function deny () { Date$(date "%F-%H-%M&q…

c程序预处理器的设计与实现_C预处理器-能力问题与解答

c程序预处理器的设计与实现C programming Pre-processor Aptitude Questions and Answers: In this section you will find C Aptitude Questions and Answers on Pre-processor topics like #define, #undef, #if, #endif etc. C编程预处理程序能力问题和解答&#xff1a;在本…

系统日志管理

1 查看系统中的日志 rsyslog 此服务是用来采集系统日志的&#xff0c;他不产生日志&#xff0c;只是起到采集作用 2 rsyslog 的管理 /var/log/messages服务信息日志/var/log/secuer系统登陆日志/var/log/cron定时任务日志/var/log/maillog邮件日志/var/log/boot.log系统启动日…

pythonassertbug_还在 Bug 不断?不妨试试这 2 个装X技巧

原标题&#xff1a;还在 Bug 不断&#xff1f;不妨试试这 2 个装X技巧作者 | luanhz来源 | 小数志(ID&#xff1a;Datazhi)程序员每天遇到 bug 就像喝水吃饭一样稀松平常&#xff0c;关键在于怎么高效而不失优雅的面对这些 bug&#xff01;所以&#xff0c;你还在固执的使用 tr…

iOS10 UI教程视图的边界与视图的框架

2019独角兽企业重金招聘Python工程师标准>>> iOS10 UI教程视图的边界与视图的框架 iOS10 UI视图的边界 在视图的几何形状中我们提到了视图属性中的一部分属性可以将定义的视图绘制在屏幕上。其中典型的3个属性为边界属性、框架属性以及中心位置属性。 bounds表示的就…

Java System类runFinalization()方法及示例

系统类runFinalization()方法 (System class runFinalization() method) runFinalization() method is available in java.lang package. runFinalization()方法在java.lang包中可用。 runFinalization() method is used to run the finalize() methods of any object that are…

Linux中远程文件的传输

1. scp命令 scp file userip:/dir 把自己主机的文件远程复制到其他主机 scp userip:/file dir 把其他主机的文件远程复制到当前主机 注意&#xff1a;要关闭接受端的防火墙 把主机的file远程复制到IP为172.25.254.117的root用户的Desktop 把IP为172.25.254.117的root用户Deskt…

svn: Can't convert string from 'UTF-8' to native

详见&#xff1a;http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt227 svn 版本库中有文件是以中文字符命名的&#xff0c;在 Linux 下 checkout 会报错&#xff1a; svn: Cant convert string from UTF-8 to native encoding 然后 checkout 程序就退出了&#xff…

引入antd组件样式_个人作品:一个技术栈koa2+ mysql+react + antd的个人博客

前言此项目是个人博客&#xff0c;有前端界面后台管理系统&#xff1b;目的是当做react和node的练手项目&#xff0c;同时还可以了解到服务器nginx部署web站点以及备案和域名的基本操作流程。项目预览地址https://www.lxsblog.cn​www.lxsblog.cnGitHub地址LinWeb/blog​github…

Java ObjectOutputStream writeLong()方法与示例

ObjectOutputStream类writeLong()方法 (ObjectOutputStream Class writeLong() method) writeLong() method is available in java.io package. writeLong()方法在java.io包中可用。 writeLong() method is used to write the given 8 bytes long value. writeLong()方法用于写…

浅谈Jfinal急速开发框架

2019独角兽企业重金招聘Python工程师标准>>> 使用Jfinal一段时间了,记得当初14年吧,为了建立一个简单的门户网站,想找个轻量型的急速开发框架,然后搜到Jfinal,然后用了一段时间后,确实不错, 现在吧,随着时间的推移,作者对JFinal的版本迭代也是一直在努力,一直朝着优…

make 怎么降级_Ubuntu 中将 make 的版本降低

最新的 Ubuntu 版本使用的是 make 版本是 4.0.在编译 Android4.4 源码包时&#xff0c;由于 make 版本过高&#xff0c;命令提示行会提示编译 Android4.4 源码包需要 make 的版本为 3.81 或 3.82.build/core/main.mk:42: ****************************************************…

Java ObjectOutputStream writeChar()方法与示例

ObjectOutputStream类writeChar()方法 (ObjectOutputStream Class writeChar() method) writeChar() method is available in java.io package. writeChar()方法在java.io包中可用。 writeChar() method is used to write 2 bytes of a character value. writeChar()方法用于写…

虚拟机的管理

我们采用虚拟机的原因是什么呢&#xff0c;很简单就俩字&#xff1a; 节能 1. 管理虚拟机的命令&#xff1a; virt-manager开启虚拟机管理器virsh list显示正在运行的虚拟机virsh list --all查看所有虚拟机virsh start desktop打开虚拟机virsh shutdown desktop正常关闭虚拟机…

mybatis对java自定义注解的使用——入门篇

转自&#xff1b;https://www.cnblogs.com/sonofelice/p/4980161.html 1. 最近在学习spring和ibatis框架。 以前在天猫实习时做过的一个小项目用到的mybatis&#xff0c;在其使用过程中&#xff0c;不加思索的用了比较原始的一种持久化方式&#xff1a; 在一个包中写一个DAO的接…

Java BigDecimal toBigIntegerExact()方法(带示例)

BigDecimal类的toBigIntegerExact()方法 (BigDecimal Class toBigIntegerExact() method) toBigIntegerExact() method is available in java.math package. toBigIntegerExact()方法在java.math包中可用。 toBigIntegerExact() method is used to convert this BigDecimal int…

Linux中的软件管理

1. 使用已有的网络安装资源安装软件 cd /etc/yum.repos.d/ (移动到yum源指向的文件配置目录下&#xff09; vim westos.repo &#xff08;新建文件&#xff0c;yum下后缀必须为.repo) 编辑这个文件里面写 [redhat] &#xff08;软件仓库名称&#xff09; namefirefox &#x…