Beginning Visual c

Embed Size (px)

Citation preview

  • 8/3/2019 Beginning Visual c

    1/18

    Click to edit Master subtitle style

    4/28/12

    Beginning Visual C#

    2010

    Session 1 - 1

  • 8/3/2019 Beginning Visual c

    2/18

    4/28/12

    Agenda

    What Is C#? Applications You CanWrite With C#

    Visual Studio 2010 And Visual C#2010 Express Edition

    A Simple C# Console Application

    A Simple C# Windows Application

    Basic C# Syntax

    Comments In C#

  • 8/3/2019 Beginning Visual c

    3/18

    4/28/12

    Applications You Can

    Write with C#C# is one of the languages you canuse to create applications that will

    run in the .NET CLR. It is an evolutionof the C and C++ languages and hasbeen created by Microsoftspecifically to work with the .NETplatform.

    Applications You Can Write with C#

  • 8/3/2019 Beginning Visual c

    4/18

    4/28/12

    Applications You Can

    Write with C#Windows applications: Applications,such as Microsoft Office, that have a

    familiar Windows look and feel aboutthem. This is made simple by usingthe Windows Forms module of the.NET Framework, which is a library of controls (such as buttons, toolbars,menus, and so on) that you can useto build a Windows user interface

    (UI).

  • 8/3/2019 Beginning Visual c

    5/18

    4/28/12

    Visual C#

    2010 Express EditionMicrosoft Visual Studio is aprogramming environment used to

    create graphical user interface (GUI)applications for the MicrosoftWindows family of operatingsystems.

    To get Microsoft Visual C# 2010Express Edition, you can download itfree from the Microsoft web site.After downloading it, you can install

  • 8/3/2019 Beginning Visual c

    6/18

    4/28/12

    Visual Studio 2010 Start up Page

  • 8/3/2019 Beginning Visual c

    7/184/28/12

    The Studio Windows

    Auto Hiding a Window

  • 8/3/2019 Beginning Visual c

    8/184/28/12

    The Studio Windows

    Docking a Window to a Side of theStudio

  • 8/3/2019 Beginning Visual c

    9/184/28/12

    Getting Started withC# .NET

    A Simple C# Console ApplicationCreate a new console application project

    by selecting File New Project in VS or

    File New Project.

    When you click on New Project, you'llsee the following dialogue box appear:

  • 8/3/2019 Beginning Visual c

    10/184/28/12

    A Simple C# ConsoleApplication

    When you click OK, a new ConsoleApplication project will be created

    for you. Some code should bedisplayed:

  • 8/3/2019 Beginning Visual c

    11/184/28/12

    A Simple C# ConsoleApplication

    Once the project is initialized, addthe following lines of code to the file

    displayed in the main window:namespace ConsoleApplication1

    {

    class Program{

    static void Main(string[] args)

  • 8/3/2019 Beginning Visual c

    12/184/28/12

    A Simple C# Windowsapplication

    To create a C# Windowsapplication:

    On the File menu, click New Project.Select Windows Forms Application asyour project type.

    Change the name of yourapplication. Click OK.

  • 8/3/2019 Beginning Visual c

    13/184/28/12

    A Simple C# Windowsapplication

    Visual C# Express Edition creates anew folder for your project that isnamed after the project title, andthen displays your new WindowsForm, titled Form1 in Designer view.

    You can switch between this viewand Code view at any time by right-clicking the design surface or codewindow and then clicking View Code

    or View Designer.

  • 8/3/2019 Beginning Visual c

    14/184/28/12

    A Simple C# Windowsapplication

    Notice the Solution Explorer on theright side of your screen. (If youcan't see the Solution Explorer, clickits entry on the View menu at thetop of Visual C# Express.) If youcompare it with the Solution Explorerwhen you created your ConsoleApplication, you'll see there's onlyone difference - the Form.

  • 8/3/2019 Beginning Visual c

    15/184/28/12

    Basic C# Syntax

    C# code is made up of a series of statements, each of which isterminated with a semicolon.Because whitespace is ignored,multiple statements can appear onone line, although for readability it isusual to add carriage returns aftersemicolons, to avoid multiplestatements on one line.

  • 8/3/2019 Beginning Visual c

    16/184/28/12

    Comments in C#

    Comments are self-explanatory: They enable you to add descriptive

    text to your code in plain English(or French, German, Mongolian, andso on) which is ignored by thecompiler.

    /* This is a comment */

    /* And so...

    ... is this! */

  • 8/3/2019 Beginning Visual c

    17/184/28/12

    Variables and Data Typesin C#

    Programmers work by manipulatingdata stored in memory. Thesestorage areas come under thegeneral heading of Variables .

    Data types are used everywhere in aprogramming language like C#.Because it's a strongly typedlanguage, you are required to informthe compiler about which data typesyou wish to use every time you

  • 8/3/2019 Beginning Visual c

    18/184/28/12

    Variables and Data Typesin C#