Today in Engineer's World, we
are Guiding you how to code your very first C# program in very easy way. Posted
By- +Manish Kumar Gautam +LIVE VIAR +ASP.NET SOLUTIONS
Click imagination hunt to
see latest Blogs
Previous
- Concept behind .exe and .dll in C#
First
C# Program
What
is C#?
Definition: C# is a beautiful,
structured, easy and type-safe object oriented language that enables developers
to build a variety of secure and useful applications that run on the .NET Framework.
First
Program:
Doing a new thing for the
first time is really exciting to tell to anybody- I am sharing my first
experience of doing programming.
As I have already explained
that C# can be used to create Windows Application, Console Application, Web
Application and many more
We would build our first
program in Console Application.
But before start. One thing
you need to have is a tool that understands C# language. As I am using Visual
Studio (VS) for creating all these Applications. As Visual Studio is Microsoft
flagship tool. So it's good to use it.
Now, you have the tool and
you are excited to start. So,
Let's start doing coding.
Console
Application:
Open your Visual Studio by
Right clicking the icon. Make a habit to open it in Run as Administrator. As
the VS start the window or the page that you get by default is called as the
Start Page.
Go to the File Menu -> New
-> Project.
Here you find all the list of
Applications that can be made in .NET. Select the Console Application. Here,
you find three entries that need to be filled.
o
Name- Specify the Project name
here.
o
Location- Specify the location of the
Project by browsing the path.
o
Solution
Name- It
will automatically take the Project name.
After filling the basic
entries click OK button.
Note: There is a bar with blue color at the
lower side of the application, which tell us about the status of the
application. Currently, it is showing "Ready" means the application
is ready for service.
By default, there is a
Program.cs file available. If not then press Shift+Alt+C, choose the
"Class" Item and name it with .cs extension. Write the following line
of code under Main method.
Explained code:
Refer Blog Namespace
And Build Solution or Press
F6. This command will compile the code. The status bar will tell you the
status. If you got the message "Build Succeeded". Then, Press
Ctrl+F5, this will run the code and output is shown in a cmd (command line)
window.
That's it! You've just
written your first C# application. Not too hard, right? Visual Studio does most
of the work for you.
For any query, comment us
below.
Next - Decision making C# concept
Related
Questions: -
Q-1
What is Console Application?
Ans. A console application is a
computer program designed to be used via a text-only computer interface, such
as a text terminal, the command line interface of some operating systems.
Q-2 What is the difference between public, static and
void?
Ans. All these are access modifiers in C#. Public declared variables or methods are accessible anywhere in the application. Static declared variables or methods are globally accessible without creating an instance of the class. And Void is a type modifier that states that the method or variable does not return any value.
Ans. All these are access modifiers in C#. Public declared variables or methods are accessible anywhere in the application. Static declared variables or methods are globally accessible without creating an instance of the class. And Void is a type modifier that states that the method or variable does not return any value.
Click imagination hunt to
see latest Blogs
Keep learning and sharing...
No comments:
Post a Comment