如何在c#中区分字符串 [英] how to diffrence strings in c#

查看:92
本文介绍了如何在c#中区分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简单的查询:



simple querstion:

string a="1" (string)
string b="2" (string)





我想知道哪个更大?



不使用(转换或int.tryParse)

in c#??



- ------------------------------------

德尔福七有可能



I want to know which is bigger؟

Without use(Convert or int.tryParse)
in c#??

--------------------------------------
Delphi seven it was possible

in delphi:
if('1'<='2')
begin  
end

推荐答案

Ar那些你在Delphi中使用的字符?



在.NET中你可以使用这两种方法来检查字符串。但是,让我们将它们更改为字符,你会看到同样的方法也适用于此。



Aren't those characters you're using in Delphi?

In .NET you can use those two methods, to check the integer representation of the string. But, lets change them to characters, and you'll see that this same method works here too.

// condition...
if('1' <= '2') {
   // what to do
   Console.WriteLine("Works");
}





..以上代码在控制台中打印Works,这里 [ ^ ]自己尝试一下。



您也可以将它们用作变量,例如





.. above code printed "Works" in the Console, here[^] give it a try yourself.

You can use them as variables too, such as

// variable initialization and declaration
char a = '1';
char b = '2';
// condition
if(a <= b) {
   // what to do...
   Console.WriteLine("Works");
}





使用字符串而不使用Convert或Int.TryParse对你不公平?试试这个 dotnetperl [ ^ ]链接了解更多。



Wasn't it unfair of you, to use strings and not use Convert or Int.TryParse? Try this dotnetperl[^] link for more.


希望此链接有助于解决您的问题:



http://www.dotnetperls.com/string-compare [ ^ ]
hope this link will help to solve your query :

http://www.dotnetperls.com/string-compare[^]


这篇关于如何在c#中区分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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