Friday 27 May 2016

Introduction of C#

Introduction of c#Sharp

C# is a object oriented programming language. In object oriented methodology a program consists of various objects that interact with each other.

C# is widely used to developing windows application, web application and services. It’s very easy to learn but need lots of practice.
IDE stands for Integrated Development Environment. It is tool that enables you to create c# application.
Microsoft provides the following tools:
Visual Studio, Visual C#, Visual Web Developer
It is available in Microsoft official website. Using these tools you can write all kinds of c# programs
There is other list of tool to develop c# application are Notepad, NotePad++ and so on.
OOPS stands for object oriented programming structure. OOPS simple means that everything is an object of class.
For example if you want to print “Developer” string on command prompt screen then you need System namespace and need to call Console.Writeline() where Console is a static class of system namespace and Writeline is the static method of console class. There is also Write, Read, ReadLine, etc. methods in console class.
For developing c# application you need to understand basic structure.
1. Namespace
2. Class, Methods, Attributes
3. Purpose of Main methods
4. Statement and Expression
5. Comments

Namespace is collection of types, classes, interfaces, structure, enumeration and delegates. It is used to organize your code.
Main Namespace in c# is System.
Declaration of namespace with using keyword: It is used to declare or include system namespace in the program.
A program has multiple namespace.

Class is enable you to create complex custom types in where you can create fields, methods, constructor, classes, interfaces, enum, delegates, types and methods.
Declaration of class:
using class keyword you can create class. By default class is internal access modifier. You can modify access modifier like private, public, protected, protected internal.

Purpose of Main() method
Main method is the entry point of console and wpf application that
“tells compiler to compile from start to end of execution” Main method state that what class does when Main is executed.

Comments
Comment tells compiler to ignore comment line and jump to next execution line.
There is two ways you can give comment into c# application
  1. Single Line comment ( // using double slaces)
  2. Multiline comment ( /*…*/ using slace with * and end with * slace )
Declaration of Comment in c#
Main method has no return type.
1. C# is case sensitive.
2. All statement and expression must end with semicolon(;).
3. The program start execution at the main method.
4. Unlike java c# file name could be different from the class name.
To start create C# program do following steps:
  1. Start Visual studio
  2. On the menu bar chose File > New > Project
  3. Choose Visual C# from left tree bar of popup window
  4. Choose console application
  5. Give a nice name of C# program and press ok
  6. You can see program.cs file in the right solution bar
  7. Write the code
  8. Execute or Run the code using F5 key or you can execute from menubar debug and click on start debug

To compile c# program using command line (CMD prompt)
  1. Open notepad write code using namespace class and main method.
  2. Save fine with .cs extension
  3. Open command prompt using run >> “cmd” or “command” and then press run
  4. Now type csc and file name or file path
you can also visit:  www.mybook-lang.com

No comments:

Post a Comment