Definition Definition

C# Programming

C# (pronounced “C sharp”) a programming language developed by Anders Hejlsberg (the developer of Turbo Pascal and Delphi) for Windows programming under Microsoft’s .NET Framework.

C# is similar in appearance and intent to Java, but it is more tightly tied to the object-oriented operating-system interface of the .NET Framework.

In some ways it reflects the spirit of Pascal, with clean and simple design, but it is fully object-oriented. Memory allocation is automatic, and programmers do not normally manipulate pointers. Care has been taken to make common operations simple and concise, and the handling of windows is especially straightforward; programmers never have to declare handlers for events that they do not actually want to handle.

A sample program in C# is :

// Sample C# program to test whether a number is prime.
using System;
class primecheck
	static void Main(string[] args)
	int n, i, max;
	bool cont;
	string s;
	while (true)
		Console.Write(”Type a number (0 to quit): ”);
		n = Convert.ToInt32(Console.ReadLine());
		if (n==0) break;
		s = ”prime”;
		cont = (n > 2);
		i = 1;
		max = (int)Math.Sqrt(n); // largest divisor to try
		while (cont)
			Console.WriteLine(”Trying divisor {0}”,i);
				if (n % i == 0) //if n divisible by i
					s = ”not prime”;
					cont = false;
					cont = (i < max);
			Console.WriteLine(”{0} is {1} \n”,n,s);
Share it: CITE

Related Definitions