⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logicaloperators.cs

📁 this is a good book for the visual c#
💻 CS
字号:
// Fig. 5.20: LogicalOperators.cs
// Demonstrating the logical operators.
using System;

namespace LogicalOperators
{
   /// <summary>
   /// Summary description for Class1.
   /// </summary>
   class LogicalOperators
   {
      /// <summary>
      /// The main entry point for the application.
      /// </summary>
      [STAThread]
      static void Main(string[] args)
      {
         // testing the conditional AND operator (&&)
         Console.WriteLine( "Conditional AND (&&)" +
            "\nfalse && false: " + ( false && false ) +
            "\nfalse && true:  " + ( false && true ) +
            "\ntrue && false:  " + ( true && false ) +
            "\ntrue && true:   " + ( true && true ) );

         // testing the conditional OR operator (||)
         Console.WriteLine( "\n\nConditional OR (||)" +
            "\nfalse || false: " + ( false || false ) +
            "\nfalse || true:  " + ( false || true ) +
            "\ntrue || false:  " + ( true || false ) +
            "\ntrue || true:   " + ( true || true ) );

         // testing the logical AND operator (&)
         Console.WriteLine( "\n\nLogical AND (&)" +
            "\nfalse & false: " + ( false & false ) +
            "\nfalse & true:  " + ( false & true ) +
            "\ntrue & false:  " + ( true & false ) +
            "\ntrue & true:   " + ( true & true ) );

         // testing the logical OR operator (|)
         Console.WriteLine( "\n\nLogical OR (|)" +
            "\nfalse | false: " + ( false | false ) +
            "\nfalse | true:  " + ( false | true ) +
            "\ntrue | false:  " + ( true | false ) +
            "\ntrue | true:   " + ( true | true ) );

         // testing the logical exclusive OR operator (^)
         Console.WriteLine( "\n\nLogical exclusive OR (^)" +
            "\nfalse ^ false: " + ( false ^ false ) +
            "\nfalse ^ true:  " + ( false ^ true ) +
            "\ntrue ^ false:  " + ( true ^ false ) +
            "\ntrue ^ true:   " + ( true ^ true ) );

         // testing the logical NOT operator (!)
         Console.WriteLine( "\n\nLogical NOT (!)" +
            "\n!false: " + ( !false ) +
            "\n!true:  " + ( !true ) );
      }
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -