Introduction to C - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Introduction to C

Description:

Collections. Resources. Reflection. Net. IO. Threading. Text. ServiceProcess. Security. Runtime ... Form Editor/Designer. Controls Toolbox. Your First C# Program ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 31
Provided by: jonapr
Category:

less

Transcript and Presenter's Notes

Title: Introduction to C


1
Introduction to C
  • Introduction to .NET

2
Agenda
  • What is .NET?
  • C as related to VB, C, and Java
  • MSIL
  • Overview of Object-Oriented Programming (OOP)
  • The Integrated Development Environment
  • Your first C program

3
.NET Overview
4
What is .NET?
  • Development Framework
  • Provides an API (application programming
    interface) to Windows
  • Convergence of multiple Microsoft technologies

5
Doing Cool Things Easily!
  • Major investment by Microsoft to see .NET succeed
    (80 of MS RD)
  • New languages
  • C (extends Java/VB/C)
  • VB.NET (strengthens VB 6.0)
  • Devices
  • Compact .NET Framework runs on PDAs, cell phones,
    game boxes, etc.

6
.NET Framework Architecture
Microsoft Visual Basic .NET
C
C
Microsoft JScript

Microsoft Visual Studio .NET
Common Language Specification
Framework Class Library
Common Language Runtime
Windows
LINUX
7
What Does .NET Offer?
  • Platform independence
  • Language independence
  • Modern language features
  • Improvements to ADO and VB
  • RAD for C/C (finally!) via C

8
.NET Framework Classes
9
C as Related to Other Languages
10
C and other Modern Languages
  • C is the evolution of VB, Java, and C
  • Leverages the Rapid Application Development (RAD)
    drag and drop of VB
  • Leverages the strong language features of C and
    Java
  • Very Java-like
  • Switching from C to another language should
    prove easy to you

11
Platform Independence
  • Write once, run anywhere
  • Compile to MSIL (open standard)
  • Deploy to many operating systems
  • The CLR handles JIT to native code
  • Akin to the Java Virtual Machine (JVM)

12
Language Independence
VB API
Java WFC
C MFC
Each language uses different APIs
13
Language Independence
VB API
Java WFC
C MFC
.NET CLR
Unified, object-oriented, hierarchical, extensible
set of class libraries
14
RAD in C
  • Windows development in C
  • Win32 API or MFC
  • Lots of nasty details
  • 300 lines of code (6 pages!)just for Hello
    World
  • No easy way to Rapid Application Development

15
The Old Way Just to Create a Window?
  • hWnd CreateWindow( "GenericAppClass","Generic
    Application", WS_OVERLAPPEDWINDOWWS_HSCROLLWS_VS
    CROLL,0,0,CW_USEDEFAULT,CW_USEDEFAULT,NULL,N
    ULL,hInstance,NULL )

16
Creating a Window in C
  • namespace HelloWorld
  • public partial class Form1 Form
  • public Form1()
  • InitializeComponent()
  • static class Program
  • STAThread
  • static void Main()
  • Application.EnableVisualStyles()
  • Application.Run(new Form1())

17
RAD in C (cont)
  • Drag-Drop interface building (ala VB)
  • Auto-generates code for control properties
  • Collapsible code regions
  • Intellisense (code complete)
  • Dynamic help/reference

18
Microsoft Intermediate Language (MSIL)
19
MSIL
  • Microsoft Intermediate Language
  • Similar to Java Bytecode
  • Language neutral and platform neutral
  • Go from any .NET language to MSIL
  • Go from MSIL to any native machine code

20
MSIL Language Independence
  • Write in any .NET language
  • C, VB.NET, J, C.NET, OTHERS!
  • Compile to MSIL
  • JIT compilation to native code

VB.NET
C
MSIL
Native

Vis J
21
Introduction to Object-Oriented Programming
22
Object-Oriented Programming
  • We will discuss OOP later in detail
  • But since all C programs are Object-oriented,
    you need to know basics
  • A class combines data and actions (also known as
    methods/functions)
  • A Person class combines information about hair
    color, age, weight, etc. along with actions like
    run, eat and sleep.
  • An object is an instance of a class
  • Alice is an object/instance of the Person
    class consequently, she has a specific hair
    color, age, weight, etc.
  • Bob is another object/instance of the Person
    class he has different hair color, age, weight,
    etc. from Alice
  • Object communicate by sending messages

23
Why Talk about OOP?
  • For a while, well gloss over the details of the
    OOP in C
  • Well focus on general ideal like how to store
    and manipulate data
  • As a result, youll see a lot of code that well
    ignore for now
  • Assume the magic works well discuss in detail
    whats going on later

24
Integrated Development Environment (IDE)
25
Various IDEs
  • The IDE serves to help write your programs
  • Certainly you can just use Notepad and the
    console-based compiler
  • But the IDE makes building, testing, and running
    your programs MUCH easier

26
Current C IDEs
  • MANY different IDEs for C
  • .NET Framework 1.0 / 1.1
  • Studio .NET 2002 (deprecated)
  • Studio .NET 2003 (lacks some new features)
  • .NET Framework 2.0
  • Studio .NET 2005 Beta
  • Studio .NET 2005 Beta 2
  • Studio .NET 2005 Express for C (lightweight)
  • Studio .NET 2005 Express for Web Development

27
The C Studio .NET 2005 Express IDE
Solution Explorer
Controls Toolbox
Form Editor/Designer
Properties Editor
28
Your First C Program
29
Responding to The Button Click Event
  • private void buttonCompute_Click(object sender,
    EventArgs e)
  • TimeSpan difference
  • DateTime currentTime DateTime.Now
  • int age
  • difference currentTime.Subtract(dateTimePicker
    BD.Value)
  • age difference.Days
  • MessageBox.Show("You are " age " days
    old.")

30
Conclusion
  • You should know a little bit about .NET
  • MSIL
  • How C relates to Java, C, and VB
  • You should have an idea of how to use the C
    Studio .NET 2005 Express IDE
  • You should know how to create a form
  • You should be familiar with the Button, Label,
    and DateTimePicker classes
  • You should know how to display a message box
Write a Comment
User Comments (0)
About PowerShow.com