Lecture 1

secrettownpanamanianMobile - Wireless

Dec 10, 2013 (3 years and 4 months ago)

39 views

Lecture 1
.NET and C# Introduction
CPICS Lecture 1
1
CE00526-2
Recommended Text
C# For Programmers, Second Edition
ISBN: 0-13-134591-5
Prentice-Hall © 2006
Methodical approach with useful
supporting web-site.
CPICS Lecture 1
2
CE00526-2
Some useful Webs
C# ecma standard #334
http://www.jaggersoft.com/csharp_standard/
ecma -"European Computer Manufacturers Association"
Non-Windows .NET platforms
http://www.mono-project.com/Main_Page
Linux,Solaris, Mac OS X, Unix and (Windows).
http://dotgnu.org/
Open-source implementation of the
Common Language Infrastructure(CLI)
".NET" NB CLI is also an ecma standard.
Microsoft C# Language Reference
http://msdn2.microsoft.com/en-us/vcsharp/
aa336804.aspx
MSDN fundamentals of C# and .NET
Recommended Text Web
http://www.deitel.com/books/csharpforprogrammers2/
C# 2.0
Visual C# 2005 Express Edition
CPICS Lecture 1
3
CE00526-2
The .NET framework
.NET is an “augmentation” to the O/S
that provides a multi-language platform
for rapidly building applications.
Windows
LINUX
Common Language Runtime
Framework Class Library
Common Language Specification
VB
C++
C#
Microsoft
JScript
®

Microsoft
Visual Studio
®
.NET
Visual Sudio provides a drag and drop
facility for rapidly developing GUI, Web-
design and database, code.
CPICS Lecture 1
4
CE00526-2
Common Language Runtime
The CLR provides the JITer (Just In Time
Compiler) which translates the IL into
native code for the target machine.
Common Language Runtime
• Execution environment
• Memory management
• Garbage collection
The IL code speed is close to that of
the native code in terms of execution
speed.
CPICS Lecture 1
5
CE00526-2
Framework Class Library
Below are just a few of the namespaces
provided bythe FCL.
Framework Class Library
• System
• System.Collections
• System.Drawing
• System.IO
• System.Data
• System.Windows.Forms
• System.Web.UI
• System.Web.Services
• System.Threading
• …
The appropriate namespace resources
are incorporated into a program via the
using construct.
CPICS Lecture 1
6
CE00526-2
The .NET Philosophy
C#
Code
C#
Compiler
Visual Basic
Code
VisualBasic
Compiler
COBOL
Code
COBOL
Compiler
IL
JIT
Compiler
Native
Code
Run
Time
CPICS Lecture 1
7
CE00526-2
Benefits of .NET
• A managed execution environment
• Libraries
• Application Programming
Interfaces (APIs) for writing
Internet-based software
• Language interoperability
• An Integrated Development Environment
(IDE) for rapid application development
• An interesting new language: C#
• Standards
• Web-efficient code
CPICS Lecture 1
8
CE00526-2
Rationale for C#
• Designed specifically for writing
.NET code
-.NET Framework–specific language
constructs
- Modern language features
― foreach
― Properties
― Indexers
―Type safety
• An improvement over existing languages
• Pedagogically sound
CPICS Lecture 1
9
CE00526-2
Constructs
Operators
and Expressions
C++ - like
Arrays 1-D,
multi-D,
jagged
Control flow if
switch
return
break
Iteration for
while
do while
foreach
Types primitive
enumerated
structs
object
CPICS Lecture 1
10
CE00526-2
Common Type System
object
value types
reference types
Classes, arrays, ...
Allocated on managed
heap.
Assignment copies
reference.
Garbage collected.
Primitive types
(int, double, …)
Allocated on stack.
Assignment copies
value.
Deallocated when
defining block exits.
User-defined types:
enumerated,
structs (lightweight
objects).
Lecture 1 CE00526-2
11
Classes

Single inheritance

Multiple interfaces

Members

Fields, methods (including
constructors), properties,
indexers, events

Access modifiers: public,
protected, internal, private

Static and instance members

Abstract (for polymorphism)

Nested types
Lecture 1 CE00526-2
12
Program Development

Command-line compiler

Simple

Slow

Ideal for learning

Visual Studio .NET

Professional

Fast

Gui

Reverse-Engineer to use
as a “learning environment”
Two Modes :-
Lecture 1 CE00526-2
13
WinForms

Visual Studio .NET brings
the power of visual design
to all the available langs

GUI toolkit

"Code-behind" model for
GUI programming

Scaffolding code generated
automatically

RAD
Lecture 1 CE00526-2
14
Visual Studio .NET

Full-featured IDE

Project manager

Code editor

Compiler

Debugger

Microsoft IntelliSense®

Name completion

Method selection

Dynamic help
Lecture 1 CE00526-2
15
Command-line mode
// namespace containing Console I/O
using System ;
public class HelloWorld
{
public static void Main()
{
Console.Write("Hello World !");
}
}
>notepad HelloWorld.cs
>csc HelloWorld.cs
>HelloWorld
Edit
C# Compile
Run
Lecture 1 CE00526-2
16
Visual Studio mode
Invoke Console Application option
for C#.
Lecture 1 CE00526-2
17
Visual Studio mode …
Enter the one-line program and then
debug to run it !
Index
1
2
3
4
5
6
7
8
9
10
Recommended Text
Some Useful Webs
The .NET framework
Common Language RunTime
Framework Class Library
The .NET Philosophy
Benefits of .NET
Rationale for C#
Constructs
Common Type System
Index
11
12
13
14
15
16
17
Classes
Program Development
WinForms
Visual Studio .NET
Command-line mode
Visual Studio mode
Visual Studio mode …