Sams Teach Yourself C in 21 Days

(singke) #1
Object-Oriented Programming Languages 645

BD1


The C# Programming Language ........................................................................


Released to the public in June 2000, C#—pronounced See Sharp—has not been around
for very long. C# is a new language created by Microsoft and submitted for standardiza-
tion to ECMA.
C# was created to remove a lot of the problems that other programming languages had. It
was intended to be a language that could be used going into the future. You’ll see that C#
looks a lot like C, C++, and Java. Listing B1.4 presents a simple C# program. On the
seventh bonus day you will be introduced to C#.

LISTINGB1.4 sample.cs. A simple C# program
1: // app.cs - A sample C# application
2: //-----------------------------------------------
3:
4: using System;
5:
6: class sample
7: {
8: public static void Main()
9: {
10: //Declare variables
11:
12: int radius = 4;
13: const double PI = 3.14159;
14: double area;
15:
16: //Do calculation
17:
18: area = PI * radius * radius;
19:
20: //Print the results
21:
22: Console.WriteLine(“Radius = {0}, PI = {1}”, radius, PI );
23: Console.WriteLine(“The area is {0}”, area);
24: }
25: }

DOconsider learning C++ or Java if you
need to write large, complex programs.

DON’Tabandon C, because it is very use-
ful for many types of small-to-medium
sized programming projects.

DO DON’T


36 448201x-Bonus1 8/13/02 11:18 AM Page 645

Free download pdf