Dashboard > People > Jim Hamilton > Home > Fun with C-Sharp
  Jim Hamilton Log In   View a printable version of the current page.  
  Fun with C-Sharp
Added by Jim Hamilton, last edited by Jim Hamilton on Jul 10, 2007  (view change)
Labels: 
(None)

C# is available on most XP workstations. To determine if it is installed, look in the C:\WINDOWS\Microsoft.NET\Framework\ folder and see if there are any "V" folders present; if so, the highest version folder is the one in which you will want to work. Copy the following code into Notepad and save it into this folder as "hello.cs" (any or no extension will work, but "cs" stands for C-Sharp and is customary):

class HelloWorld
{
  static void Main ()
  {
    System.Console.Write("Hello World!");
  }
}

Next, open a CMD (DOS) window and navigate to the folder you are using.  To compile the program, type "csc hello.cs" and you should see something similar to:

Microsoft (R) Visual C# .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.

This compiles the "hello.cs" source code into "hello.exe" which you can now run by typing "hello" and finally be rewarded with:

Hello World!

Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.5 Build:#520 Jun 27, 2006) - Bug/feature request - Contact Administrators
This wiki is a joint endeavor of the GCIS Group and the Faculty Connection Center at Glendale Community College.
We welcome feedback.  Legal Notice