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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

c 运算符##_C#程序演示关系运算符的示例

發布時間:2025/3/11 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c 运算符##_C#程序演示关系运算符的示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

c 運算符##

Relational operators are used to compare the values and returns Boolean values, if condition is true – they return True, otherwise they return False.

關系運算符用于比較值并返回布爾值(如果condition為true)-它們返回True ,否則返回False 。

Here is the list of relation operators,

這是關系運算符的列表,

  • "==" (Equal To) – it returns true, if both operand’s values are equal

    “ ==”(等于) –如果兩個操作數的值相等,則返回true

  • "!=" (Not Equal To) – it returns true, if both operand’s values are not equal

    “!=”(不等于) –如果兩個操作數的值都不相等,則返回true

  • " – it returns true if first, operand is less than second operand

    “ –如果第一個操作數小于第二個操作數,則返回true

  • "<=" (Less Than or Equal To) – it returns true, if either first operand is less than or equal to second operand

    “ <=”(小于或等于) –如果第一個操作數小于或等于第二個操作數,則返回true

  • ">" (Greater Than) – it returns true, if first operand is greater than second operand

    “>”(大于) –如果第一個操作數大于第二個操作數,則返回true

  • ">=" (Greater Than or Equal To) – it returns true, if either first operand is greater than or equal to second operand

    “> =”(大于或等于) –如果第一個操作數大于或等于第二個操作數,則返回true

  • Syntax:

    句法:

    Operand1 == Operand2Operand1 != Operand2Operand1 < Operand2Operand1 <= Operand2Operand1 > Operand2Operand1 >= Operand2

    Example:

    例:

    Input:int a = 10;int b = 3;Console.WriteLine("a==b: {0}", (a == b));Console.WriteLine("a!=b: {0}", (a != b));Console.WriteLine("a>b : {0}", (a > b));Console.WriteLine("a>=b: {0}", (a >= b));Console.WriteLine("a<b : {0}", (a < b));Console.WriteLine("a<=b: {0}", (a <= b));Output:a==b: Falsea!=b: Truea>b : Truea>=b: Truea<b : Falsea<=b: False

    C# code to demonstrate example of relational operators

    C#代碼演示關系運算符的示例

    // C# program to demonstrate example of // relational operators using System; using System.IO; using System.Text;namespace IncludeHelp {class Test{// Main Method static void Main(string[] args){int a = 10;int b = 3;//printing return typeConsole.WriteLine("Return type of == operator: {0}", (a == b).GetType());Console.WriteLine("Return type of != operator: {0}", (a != b).GetType());Console.WriteLine("Return type of > operator : {0}", (a > b).GetType());Console.WriteLine("Return type of >= operator: {0}", (a >= b).GetType());Console.WriteLine("Return type of < operator : {0}", (a < b).GetType());Console.WriteLine("Return type of <= operator: {0}", (a <= b).GetType());//printing return valuesConsole.WriteLine("a==b: {0}", (a == b));Console.WriteLine("a!=b: {0}", (a != b));Console.WriteLine("a>b : {0}", (a > b));Console.WriteLine("a>=b: {0}", (a >= b));Console.WriteLine("a<b : {0}", (a < b));Console.WriteLine("a<=b: {0}", (a <= b));//checking conditionsif (a == b)Console.WriteLine("a is equal to b");elseConsole.WriteLine("a is not equal to b");if (a != b)Console.WriteLine("a is not equal to b");elseConsole.WriteLine("a is equal to b");if (a > b)Console.WriteLine("a is greater than b");elseConsole.WriteLine("a is not greater than b");if (a >= b)Console.WriteLine("a is greater than or equal to b");elseConsole.WriteLine("a is not greater than or equal to b");if (a < b)Console.WriteLine("a is less than b");elseConsole.WriteLine("a is not less than b");if (a <= b)Console.WriteLine("a is less than or equal to b");elseConsole.WriteLine("a is not less than or equal to b");//checking conditions in another wayif ((a == b) == true)Console.WriteLine("a is equal to b");elseConsole.WriteLine("a is not equal to b");if ((a != b) == true)Console.WriteLine("a is not equal to b");elseConsole.WriteLine("a is equal to b");if ((a > b) == true)Console.WriteLine("a is greater than b");elseConsole.WriteLine("a is not greater than b");if ((a >= b) == true)Console.WriteLine("a is greater than or equal to b");elseConsole.WriteLine("a is not greater than or equal to b");if ((a < b) == true)Console.WriteLine("a is less than b");elseConsole.WriteLine("a is not less than b");if ((a <= b) == true)Console.WriteLine("a is less than or equal to b");elseConsole.WriteLine("a is not less than or equal to b");//hit ENTER to exit the programConsole.ReadLine();}} }

    Output

    輸出量

    Return type of == operator: System.Boolean Return type of != operator: System.Boolean Return type of > operator : System.Boolean Return type of >= operator: System.Boolean Return type of < operator : System.Boolean Return type of <= operator: System.Boolean a==b: False a!=b: True a>b : True a>=b: True a<b : False a<=b: False a is not equal to b a is not equal to b a is greater than b a is greater than or equal to b a is not less than b a is not less than or equal to b a is not equal to b a is not equal to b a is greater than b a is greater than or equal to b a is not less than b a is not less than or equal to b

    翻譯自: https://www.includehelp.com/dot-net/relational-operators-example-in-c-sharp.aspx

    c 運算符##

    總結

    以上是生活随笔為你收集整理的c 运算符##_C#程序演示关系运算符的示例的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。