VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > temp > C#教程 >
  • C# |通过控制台

C# |通过控制台

检查大写锁定是打开还是关闭

原文:https://www . geesforgeks . org/c-sharp-check-if-caps-lock-on-or-off-through-console/

给定 C# 中的正常控制台,任务是通过控制台检查 CAPS LOCK 是打开还是关闭。

方法:这可以使用 C# 中系统包的控制台类中的 CAPS LOCK 属性来完成。

程序 1: 当大写锁定开启时

// C# program to illustrate the
// Console.CapsLock Property
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GFG {

class Program {

    static void Main(string[] args)
    {

        // Check if CAPS LOCK is on or off
        Console.WriteLine("Is CAPS LOCK on: {0}",
                               Console.CapsLock);
    }
}
}

输出:

程序 2: 当大写锁定关闭时

// C# program to illustrate the
// Console.CapsLock Property
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GFG {

class Program {

    static void Main(string[] args)
    {

        // Check if CAPS LOCK is on or off
        Console.WriteLine("Is CAPS LOCK on: {0}",
                               Console.CapsLock);
    }
}
}

输出:




相关教程