SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Matt Ward

Your First C# Project: Hello, World

To introduce you to some of SharpDevelop's features, we will create a simple "Hello, World "Windows application. This example will be written using the C# language.

To create a new application:
  1. From the File menu, select New and then Solution... or use the shortcut Ctrl+Shift+N or click New solution on the Start Page.



    This opens the New Project dialog. This dialog shows all the various projects that SharpDevelop can create.



  2. From the New Project dialog, expand the C# category and select the Windows Application category.
  3. From the list of available templates, select Windows Application.
  4. Type in a name for the new project (e.g. HelloWorld).
  5. Enter the folder location for the new project. Type in the full path or click the browse button to use the Browse for Folder dialog to choose a folder. The default location should be fine, but you are free to choose another location for the project. In the screenshot above, the project has been given the name HelloWorld and the location has been set to "C:\Projects". At the bottom of the dialog you can see that the new project will be created in the folder "C:\Projects\HelloWorld".
  6. Click the Create button. SharpDevelop will create the project and open it. On the left hand side you can see the project in the Project Explorer. Expand HelloWorld to see all the files that project contains. In the middle the project's main form MainForm.cs is opened.



Editing the code:
  1. Now you will modify the MainForm class so the title of the window of your HelloWorld application is set to "Hello, World!". In order to do this, scroll the text of the MainForm class down until you see the MainForm's constructor, as shown below.



  2. Delete the three TODO comment lines and type in the following single line of code:

    this.Text = "Hello, World!";

    Your MainForm should now look like this.


Building the application:
  1. From the Build menu, select Build HelloWorld.



  2. As the project builds messages will appear in the Output window. If the build was successful you should see the messages as shown below.


Running the application:
  1. From the Debug menu, select Run or use the F5 keyboard shortcut.



    This will run your application and its main form will be displayed.



Published Jun 24 2006, 04:34 PM by MattWard
Filed under:

Comments

No Comments
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.