如何在C#中进行比较

Won*_*ing 1 c#

我有两个字符串.

                string a="50";
                string b="60";
Run Code Online (Sandbox Code Playgroud)

现在我想根据它们的值来扼杀字符串a和b的值,即这里b> a ..实现这一目标的最佳方法是什么?

Rob*_*Rob 5

您需要将它们转换为整数才能以数字方式对它们进行比较,因此:

string a = "50";
string b = "60";
bool isBGreaterThanA = Convert.ToInt32(b) > Convert.ToInt32(a);
Run Code Online (Sandbox Code Playgroud)