帶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.pswp.cn/news/542205.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/542205.shtml
英文地址,請注明出處:http://en.pswp.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…