Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,947 questions

51,889 answers

573 users

How to determine if a character is a letter or digit in C#

2 Answers

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "c# 1 c++ 2 java ! python ?";
            Console.WriteLine(s);

            foreach (char ch in s)
            {
                if (char.IsLetterOrDigit(ch))
                {
                    Console.Write('y');
                }
                else
                {
                    Console.Write(' ');
                }
            }
        }
    }
}


/*
run:

c# 1 c++ 2 java ! python ?
y  y y   y yyyy   yyyyyy  

*/

 



answered Mar 8, 2017 by avibootz
0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            char ch = 'w';

            bool b;

            b = char.IsLetterOrDigit(ch);
            Console.WriteLine(b);
            b = char.IsLetterOrDigit('7');
            Console.WriteLine(b);
            b = char.IsLetterOrDigit('\n');
            Console.WriteLine(b);
        }
    }
}


/*
run:

True
True
False

*/

 



answered Mar 8, 2017 by avibootz

Related questions

2 answers 168 views
1 answer 163 views
2 answers 86 views
1 answer 94 views
1 answer 168 views
1 answer 156 views
...