Introduction
Actually I have focused on rapid learning course for C Sharp programming language. Of course I will conduct from the beginning to more advanced programming. But here, I have assumed that you all are having
kind of basic knowledge in computing and basic idea in computer programming. Any how I have started with a simple program. What I do is, first is to create a
very simple program. It may helpful you, to understand how you should deal with
the C Sharp. At the end of this module, basically you may understand:
- Creating new solution projects.
- To deal with solution explorer.
- Saving the projects.
- Run the program.
Console
Application is the very simple application you can start with. Here I am using Microsoft
Visual Studio 2010 as my developing IDE.
Don’t think this
is complex too much. For the moment take it simple and interesting. Later on
you may realize that the programming is a kind of art.
Console Application
This is shown in
DOS window. The user has to deal with that interface for the moment. But
console applications are the simplest way to understand how a program works.
Open your IDE. It
may be Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, or any
Express edition. Following images may help you to open new console project in C
Sharp.
At the right hand
side you are having Solution Explorer, which is having all your related project
files. If it is not visible follow this way.
Menu bar - View - Solution Explorer
Menu bar - View - Solution Explorer
AssemblyInfo.cs
consists information about your application. You can edit the details inside
the double courts. If you have to
use any reference like .dll files or any kind of libraries, References is the
place where you have to place them.
Bellow it is shown that how you save your project. Here
by default it is saved inside my documents. But you can give any prefer location to save your
tasks. Inside the folder that you save you
project, there are few files. There is a file with .sln extension, which is the
entire solution. If you double click on that, the entire project is open with
the IDE.
Don’t think much about 3 lines that start with using. It is the way of adding references to the code. The namespace line includes the name of your application. A namespace is a way to group related code together. You can refer any related e book to find out more advanced details on these topics. Here I just want to provide a basic stat up for C Sharp programming. Word class is much important here. Whole code will be written in classes. This one is called Program. Simply think that class as a segment or kind of section of code. Inside of the class called Program there is this code:
static
void Main(string[] args)
{
{
}
This is called a Method.
The name of the Method above is Main. When you run your programme it is
initially looks for a Method called Main, as it is the starting poit of a
programme. It then executes any code between those two curly brackets. The words
I blue are called as keywords.
Console.WriteLine("I am doing programming");
Blue color words
are reserved key words of the language. Within double courts you can place any
text value. At the end of the statement it is essential to put semicolon. It is
coming under syntax of the programming language.
Test the program can be done in
several ways. It has to be built first. Here it checks whether everything is OK.
Follow the images bellow. If you can not see the out put window, simply go to
the menu bar
View - Output
Then click on the green arrow button
which has been circled with red color. It will start to debug the application.
Bellow line of code will help to hold the command
prompt until user enter any keyboard input.
Console.Read();
Introduction to Windows Form Applications
Here we are going to create Windows
Applications. Not like Console Applications, Windows Applications uses separate
interface called a Windows Form. We then add control to your form. Buttons,
text boxes, radio buttons, menus, Media controllers and etc. There we can add whatever
the controls we need to meet our requirements for the solution. The form is
kind of interface to the users to interact with. It makes it easy and more user-friendly.
That is called the front end of a application. We can program those controllers
behind the graphical interface, which is called back end. We can talk about them
later on. Let us start then.
Follow bellow steps:
This is the basic form appearance just after add new form to the project.
You can simply drag and drop necessary UI controls from this window called the Tool Box. This is how you can take this if it is not visible at the start up.
Menu Bar - View - Tool Box
Program.cs is containing the Main method of the program. Main method is the very first method that execute when the application is started to run. Here It has initialized a new form to start. We can replace this form name with the necessary name that we have assigned to a form by changing its' name from it's property window.
Right click on the name of the form in the solution explorer window as shown and select and click on view code. It will show the back end code of the form. After we add necessary controls to the form, we can move into back end and do the coding part as we want.
What the user see is only the windows form as the UI and simply deal with it, they do not suppose to have almost anything what is happening behind the interface they are using.
This is what you see after above step.
This is how the program is initialized.
Here the InitializeComponent(); is a method defined in side the Form1.Designer.cs. It is generated automatically. We do not bother on it.
You can go to Form1.Designer.cs by clicking on this.
Basic appearance of it. If you want to see the actual content of the above mentioned method, simply click on the + mark at the left side bottom.
This actually happens when new form starts. It has to be initialized first. But it is done automatically. So we are not suppose to care on it for the moment.
This is close picture of the Tool Box mentioned above. Various type of controllers are categorized into separately. You can simply add them to the form (drag and drop) and do the coding in the back end.
This is the property window. Each controller (form itself has a properties) is having various properties that can be set according to the users' wish. They are customizable.
We are going to do a little example. It may worth several time other than doing explanations.
simply go to the Tool Box and select Button control. Drag it and drop it on the form itself. It seems like this.
Double click on the Button you added. It will show the back end of the form as we have seen earlier. The cursor blinks within a pair of open and closed curly brackets.
That event has a name. The Button click event. Whatever the code written in side the parenthesis will defined, what should be performed soon after user click on the button. That is called a "button click event".
Type "MessageBox."... and so on.
The application suggests possible part of code which is called "IntelliSense ". IntelliSense is auto implement tequnique from Microsoft. It is highly used in the Microsoft Visual Studio
integrated development environment.
There are various options provided with these IntelliSense. So Each controllers are having different set of options for various purposes.
If we want to place any statement which is not to be executed by the debugger, we can use "Comments". "//" is for single line comment while "/* - */ is for multiple line comments. Both are shown here.
If you have finished the coding then you can rebuild the solution and then click on the arrow button rounded with a Red circle. It is called "Debug".
This is the out put you get at the end.
This is one very basic application for you to understand the basic concepts.
When we move forward you will be able to do really really advanced implementations as you wish.
The only thing you should have is the interest, simple logic and effort. Let your self to explore and learn more from the resources available outside.
















