Getting Started with C#, Page 2
About the Editors
Choosing an editor for coding the source code is a tedious task facing every programmer. There will be various types of editors brought out by different companies. They are elaborated below in detail.
Notepad is the best and most widely used editor among developers using .NET SDK. It comes with every edition of the Windows operating system and it's easy to use. Also, it does not require much investment.
Figure 3Hello.cs in Notepad
However, it is not the most suitable editor because it does not support syntax coloring and highlighting, compilation and execution directly from the editor, code numbering, and so forth. But as you know, Notepad in Windows 2000 Professional supports the famous Ctrl+G shortcut for finding line numbers.
Visual C++ 6.0
Developers can use Visual C++ 6.0, included with Visual Studio 6.0. However, they should do some tweaking in the Registry before using it. It supports syntax colorings and other features such as finding line numbers (Ctrl+G). However, it is dangerous for a new user to make changes in the Registry. Hence, only advanced and experienced users should use Visual Studio 6.0 for developing C#. It's not possible to compile and execute the applications from the Visual C++ 6.0 environment. Hence, it is not of much use except for some of the features listed above.
Visual Studio .NET
Visual Studio .NET provides all the integrated tools and wizards for creating C# and other .NET-based language applications. It also supports features such as Intellisense, Dynamic help, and so on. Moreover, you can compile and execute your applications from the IDE itself. Hence, to experience the power of developing the .NET applications, you should try Visual Studio .NET. But be prepared to pay a huge sum for this wonderful stuff.
Many third-party editors are now available and can be downloaded from the Internet. One such editor is called the Antechninus C# Editor. It supports color-coding, compilation and execution from the IDE, project maintenance, and accessing the .NET Framework documentation by using its help menu, and so forth. It can be downloaded free of cost from http://www.c-point.com/download/csharped.zip. Moreover, the editor comes with built-in tutorials on C#; they can be accessed from the Help menu.
However, it is up to you to decide which editor to use. I recommend you to try one common editor and learn the language in full.
The "Hello C#" Program
A majority of developers learned programming by coding the "Hello World" program. But, for a change, we will see the "Hello C#" program. As mentioned in the previous section, you can use any editor to code the program. It's your preference as to which editor to use. Listing 1 shows the coding for our "Hello C#" program:
public static void Main()
Console.WriteLine ("Hello C#");
After entering the above code in an editor, you have to perform the following steps:
- Save the file as Hello.cs. cs is an extension to indicate C-Sharp, as you would use .java for a Java source file. You have to supply this extension when saving your file; otherwise, the code will not compile correctly. The saved file will have the extension .cs.txt.
- Compile the code by giving the following command at the command prompt:
- If there are compile errors, you will be prompted accordingly. Otherwise, you will view a command prompt along with the copyright information, as shown in Figure 4.
Figure 4Compilation and Execution of "Hello C#"
- As a final step, you have to execute the program to view the final output. For that purpose, you simply give a command at the command prompt. Refer to Figure 4. If everything goes well, you can view the message "Hello C#" as shown in Figure 4.
We will analyze the preceding program in detail in the article "C# Program and Its Intermediate Language."
- Microsoft .NET Framework SDK
- Download Link
- SDK on CD-ROM
- Visual Studio home page
- More about Microsoft products
About the Author
Anand Narayanaswamy works as a freelance Web/Software developer and technical writer. He runs and maintains learnxpress.com, and provides free technical support to users. His areas of interest include Web development, software development using Visual Basic, and in the design and preparation of coursewares, technical articles, and tutorials. He can be reached at email@example.com.
# # #
Page 2 of 2