日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > C# >内容正文

C#

c#给定编码中的字符无效_C#程序检查给定的字符串是否等于(==)运算符

發(fā)布時(shí)間:2023/12/1 C# 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c#给定编码中的字符无效_C#程序检查给定的字符串是否等于(==)运算符 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

c#給定編碼中的字符無(wú)效

Input two strings and check whether they are equal or not using C# program.

輸入兩個(gè)字符串,并使用C#程序檢查它們是否相等。

用于字符串比較的C#代碼 (C# code for string comparison)

Here, we are asking for two strings input from the user and checking them whether they are equal or not using == operator and also ignoring the case.

在這里,我們要求用戶輸入兩個(gè)字符串,并使用==運(yùn)算符檢查它們是否相等,并且忽略大小寫。

// C# program to check given strings are equal or not // using equal to (==) operator using System; using System.IO; using System.Text;namespace IncludeHelp {class Test{// Main Method static void Main(string[] args){string str1;string str2;//input stringsConsole.Write("Enter a string: ");str1 = Console.ReadLine();Console.Write("Enter another string: ");str2 = Console.ReadLine();//comparing strings if (str1 == str2)Console.WriteLine("\"{0}\" and \"{1}\" are equal", str1, str2);elseConsole.WriteLine("\"{0}\" and \"{1}\" are not equal", str1, str2);//another way if ((str1 == str2) == true)Console.WriteLine("\"{0}\" and \"{1}\" are equal", str1, str2);elseConsole.WriteLine("\"{0}\" and \"{1}\" are not equal", str1, str2);//comparing by ignoring the case //convert both strings in the same case //either in uppercase or lowercaseConsole.WriteLine("By ignoring case...");if(str1.ToUpper() == str2.ToUpper())Console.WriteLine("\"{0}\" and \"{1}\" are equal", str1, str2);elseConsole.WriteLine("\"{0}\" and \"{1}\" are not equal", str1, str2);//hit ENTER to exit the programConsole.ReadLine();}} }

Output

輸出量

First run: Enter a string: IncludeHelp Enter another string: IncludeHelp "IncludeHelp" and "IncludeHelp" are equal "IncludeHelp" and "IncludeHelp" are equal By ignoring case... "IncludeHelp" and "IncludeHelp" are equalSecond run: Enter a string: includehelp Enter another string: INCLUDEHELP "includehelp" and "INCLUDEHELP" are not equal "includehelp" and "INCLUDEHELP" are not equal By ignoring case... "includehelp" and "INCLUDEHELP" are equalThird run: Enter a string: IncludeHelp Enter another string: IncludeHelp.com "IncludeHelp" and "IncludeHelp.com" are not equal "IncludeHelp" and "IncludeHelp.com" are not equal By ignoring case... "IncludeHelp" and "IncludeHelp.com" are not equal

翻譯自: https://www.includehelp.com/dot-net/check-given-strings-are-equal-or-not-using-equal-to-operator-in-c-sharp.aspx

c#給定編碼中的字符無(wú)效

總結(jié)

以上是生活随笔為你收集整理的c#给定编码中的字符无效_C#程序检查给定的字符串是否等于(==)运算符的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。