帮助bool CompareStrings [英] help in bool CompareStrings

查看:67
本文介绍了帮助bool CompareStrings的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请解释以下布尔功能.我不太了解编程,因为我对编程一无所知.请以简单易懂的方式进行说明.
谢谢

please explain the follwing bool function. I cannot comprehend it as i have little knowlege of programming. Please explain in simple and easy way.
Thanks

private bool CompareStrings(string string1, string string2)
    {
      return String.Compare(string1, string2, true, System.Globalization.CultureInfo.InvariantCulture) == 0 ? true : false;
    }

推荐答案

此函数比较2个字符串并返回布尔值.

如果两个字符串相等,则String.Compare返回0;如果第一个字符串小于2nd,则返回-1;如果第一个字符串大于2nd,则返回1.

附注:如果您缺乏编程知识,那么为什么不读书来增加它的知识呢? :)

DD说...为了公平起见,他至少提供了代码,并在标签中加了一个标签,所以不要太苛刻,这里的一些提问者比我的CCC更为神秘.
This function is comparing 2 strings and returning boolean value.

String.Compare returns 0 if both strings are equal, -1 if 1st string is less than 2nd and 1 if 1st is greater than 2nd.

P.S.: If you have little programming knowledge then why not increase it by reading a book. :)

DD says... to be fair, he at least provided code, and in a tag, so be not too harsh, some of the questioners here are more cryptic than my CCC''s.


touseef4pk写道:
touseef4pk wrote:

System.Globalization.CultureInfo.InvariantCulture

System.Globalization.CultureInfo.InvariantCulture



这部分看起来像您将要比较两个strng,并在应用基于国家/地区的差异时查看它们是否相同.
(例如,日期格式,或用于1000个分隔符的``s over,s''.)

如果相同则返回True,否则返回False.



This part looks like you will be comparing two strngs and seeing if they are the same when the diffences from a country to country basis is applied.
(Eg date formats, or .''s over ,s'' for 1000 separators.)

Returning True if the same and False if not.


看这里:
String.Compare [?:运算符 [
Look here:
String.Compare[^]
?: Operator[^]

Please buy a book and read the basics before starting programming. Or read online on MSDN or any site that suits you. You are asking too many basic questions - flooding with such questions out here is not good.


这篇关于帮助bool CompareStrings的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆