广告加工厂临淄关键词网站优化哪家好
广告加工厂,临淄关键词网站优化哪家好,构建大型网站,驻马店百度seoc#给定编码中的字符无效Input two strings and check whether they are equal or not using C# program. 输入两个字符串#xff0c;并使用C#xff03;程序检查它们是否相等。 用于字符串比较的C#xff03;代码 (C# code for string comparison) Here, we are asking for…c#给定编码中的字符无效Input two strings and check whether they are equal or not using C# program. 输入两个字符串并使用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. 在这里我们要求用户输入两个字符串并使用运算符检查它们是否相等并且忽略大小写。 // 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 strings
Console.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);
else
Console.WriteLine(\{0}\ and \{1}\ are not equal, str1, str2);
//another way
if ((str1 str2) true)
Console.WriteLine(\{0}\ and \{1}\ are equal, str1, str2);
else
Console.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 lowercase
Console.WriteLine(By ignoring case...);
if(str1.ToUpper() str2.ToUpper())
Console.WriteLine(\{0}\ and \{1}\ are equal, str1, str2);
else
Console.WriteLine(\{0}\ and \{1}\ are not equal, str1, str2);
//hit ENTER to exit the program
Console.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 equal
Second 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 equal
Third 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.aspxc#给定编码中的字符无效
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/88598.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!