Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Array problem

$
0
0
Hi everyone, first of all sorry for my english and thank you for the responses.

I'm a new programmer in c#. At the moment I'm busy with arrays. A month ago, I create a program, where the user has to put a character, after that the program had to see if it was an upppercase or a lowercase, it also can/ should what be able to recognize a number or special sign. You can specifie this, but I wanted to this with arrays. It won't work and I've been looking a couple of days now, but I can find what's wrong. Ofcourse it shows an error. But thats what I can't get right.
It's created in sharpdevelop 4.2, but I've also got visual studio 2010 ultimate.

When I try to run it, it underlines "c", in the if-statement and else-if.

This is the code.

using System;

namespace LetterArrayCA
{
	class Program
	{
		public static void Main(string[] args)
		{
			Vergelijken();
		}
		
		private static char[] Uppercase =
		{
			'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
		};
		
		private static char[] Lowercase =
		{
			'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
		};
		
		private static char[] Number = 
		{
			'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
		};
		
		public static void Vergelijken()
		{
			char c;
			Console.WriteLine("Insert an character:");
			c = Convert.ToChar(Console.ReadLine());
			
			if (c == Uppercase)
			{
				Console.WriteLine(c + " is an Uppercase");
			}
			else if (c == Lowercase)
			{
				Console.WriteLine(c + " is a Lowercase");
			}
			else if (c == Number)
			{
				Console.WriteLine(c + " is a Number");
			}
				
			Console.Read();
		}
	}
}

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>