ในการตรวจสอบว่า Caps Lock เปิดหรือปิดผ่านคอนโซลหรือไม่ โค้ดจะเป็นดังนี้ -
ตัวอย่าง
using System;
public class Demo{
public static void Main(string[] args){
Console.WriteLine("The CAPS LOCK is on or not? "+ Console.CapsLock);
}
} ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
The CAPS LOCK is on or not? False
ตัวอย่าง
ในการตรวจสอบว่า Num Lock เปิดหรือปิดผ่านคอนโซลหรือไม่ รหัสจะเป็นดังนี้ -
using System;
public class Demo{
public static void Main(string[] args){
Console.WriteLine("The Num LOCK is on or not? "+ Console.NumberLock);
}
} ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
The Num LOCK is on or not? True