4 Ways to Create a C Sharp Program

Table of contents:

4 Ways to Create a C Sharp Program
4 Ways to Create a C Sharp Program
Anonim

C # is a great programming language and all the tools you need to start using it are free and easy to use. While Visual C # is associated with Microsoft and is a closed source project, supporters of free software and open-source projects use DotGNU which provides more or less the same basic tools, while giving you the opportunity to study and modify how the program works. without any restrictions. The instructions in this guide describe both approaches: "FOSS oriented" and "Windows oriented". The C # language also exploits all the potential of the. NET framework.

Steps

Method 1 of 4: Configure Windows Environment

6593 1
6593 1

Step 1. Go to the following website and download your free copy of Visual C # 2010 Express Edition

The 2012 version is also available, if you don't have specific development needs you can opt for the 2010 version of Visual C #.

The Visual C # 2012 version is only supported on Windows 7/8

6593 2
6593 2

Step 2. Run the file you just downloaded and follow these instructions:

  • Press the Next button.

    Create a Program in C Sharp Step 2Bullet1
    Create a Program in C Sharp Step 2Bullet1
  • Accept the terms of the agreement and press the Next button.

    Create a Program in C Sharp Step 2Bullet2
    Create a Program in C Sharp Step 2Bullet2
  • Select the installation of the MSDN library, not the SQL Server, then press the Next button.

    Create a Program in C Sharp Step 2Bullet3
    Create a Program in C Sharp Step 2Bullet3
  • Press the Install button.

    Create a Program in C Sharp Step 2Bullet4
    Create a Program in C Sharp Step 2Bullet4

Method 2 of 4: Create Your First Program

6593 3
6593 3

Step 1. Launch Visual C # 2010 Express Edition

6593 4
6593 4

Step 2. Access the File menu and select the New Project item

6593 5
6593 5

Step 3. Select the Visual C # entry, choose the Windows option and finally select the Console Application object

6593 6
6593 6

Step 4. When done, press the OK button

You should see the following code:

    using System; using System. Collections. Generic; using System. Text; namespace ConsoleApplication1 {class Program {static void Main (string args) {}}}

6593 7
6593 7

Step 5. Under the static void Main (string args) piece of code, after the first opening brace, type the following code:

    Console. WriteLine ("Hello, World!"); Console. ReadLine ();

6593 8
6593 8

Step 6. The complete program should look like this:

    using System; using System. Collections. Generic; using System. Text; namespace ConsoleApplication1 {class Program {static void Main (string args) {Console. WriteLine ("Hello, World!"); Console. ReadLine (); }}}

6593 9
6593 9

Step 7. Press the Start [►] button on the toolbar

Congratulations! You just created your first C # program!

Create a Program in C Sharp Step 8Bullet1
Create a Program in C Sharp Step 8Bullet1

Step 8. The result is a Windows shell window in which the classic Hello World

  • If not, you most likely made a typo, double-check the code carefully.

    Method 3 of 4: Configure Linux Environment

    6593 10
    6593 10

    Step 1. You need to use CVS and GNU tools

    These are two programs that should be included in most Linux distributions.

    6593 11
    6593 11

    Step 2. Access the DotGNU project site (https://www.gnu.org/software/dotgnu/) which provides the FOSS implementation of C #

    Read the chapter on installation instructions. This is a simple procedure that can be performed even for a beginner.

    6593 12
    6593 12

    Step 3. You can choose to download the source code and build the C # development environment from scratch, or use a pre-compiled distribution

    The project is relatively simple to create via source code, so I recommend that you go this route.

    6593 13
    6593 13

    Step 4. Try to start with one of the sample codes included in the pre-compiled version of the development environment

    For example, the FormsTest.exe program displays a large collection of GUI interface controls. The pnetlib / samples folder contains the ilrun.sh script with which to start precompiled executable programs. In our example the command is the following sh./ilrun.sh forms / FormsTest.exe (to be launched inside the folder).

    6593 14
    6593 14

    Step 5. On Linux you can use the KWrite or gedit commands to edit the C # code

    Newer versions of both editors allow you to highlight the syntax elements for this programming language.

    6593 15
    6593 15

    Step 6. Find out for yourself how to compile the sample code provided in the Windows environment method

    If the project website doesn't provide enough documentation on this, try a Google search. If that doesn't help, send your questions to the project mailing list.

    6593 16
    6593 16

    Step 7. Congratulations, you now have two C # development environments

    In this way you can consciously choose which one is the most suitable for your needs.

    Method 4 of 4: Recommended Books

    • ISBN 0-7645-8955-5: Visual C # 2005 Express Edition Starter Kit - Newbie
    • ISBN 0-7645-7847-2: Beginning Visual C # 2005 - Novice
    • ISBN 0-7645-7534-1: Professional C # 2005 - Intermediate +

    Advice

    • Visual C # 2005/2008 Express Edition comes with an installation option that allows you to add the Microsoft MSDN 2005 Express Edition library. This is a great source of information that you can access via the program Help or by highlighting a code keyword and pressing the F1 key. Installing the MSDN library is a highly recommended step.
    • If you install Visual C # 2010/2012 Express, it will automatically download or give you the option to do so.
    • There are better implementations of C # than the ones shown in this guide. The Mono project could be very interesting for you.

Recommended: