
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Check If a Character Is a Whitespace Character in C#
Set a character with WhiteSpace −
char c = ' ';
To check if a character is a whitespace character, use the char.IsWhiteSpace method −
if (char.IsWhiteSpace(c)) {}
Let us see the complete code −
Example
using System; class Demo { static void Main() { char c = ' '; if (char.IsWhiteSpace(c)) { Console.WriteLine("Whitespace character!"); } } }
Output
Whitespace character!
Advertisements