Вы находитесь на странице: 1из 24

INTRODUCTION TO

C# PROGRAMMING

IT111P
TODAY
• How awesome is C#?
• Differentiate C++ from C#
• Distinguish the different types of applications that can be
created with C# programming language.
• Identify and examine the basic elements of a C# program.
• Interpret a program written in C# programming language.
HOW AWESOME IS C#?
• C# is as awesome as the most awesome thing in this
awesome world.
• C# is the god of programming languages. HAHA!
• C# is the tool of awesome programmers.
• C# is always there when you’re down.
• C# will never leave you (from now until your graduation).
TRUER FACTS
TIOBE Programming Community Index for December 2011
TOP 5 Programming Languages

1. Java
2. C
3. C++
4. C#
5. Objective C

From: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
THE
ACTUAL
CHART
THEY SAY…
• that C# is basically Visual Basic with C++ characteristics
• that the syntax is very similar to Java
• that C# is basically from C++ which was from C
• that C stands for _________.
• that it is awesome
FIRST
• OOP / Object Oriented Programming – The concept behind
OOP is that applications can be organized around objects
rather than processes.

• (Visual Studio).NET Framework - an environment in which


programs run and was designed to be a new programming
paradigm. It provides a platform for developing and running a
code that is easy to use.

• The .NET Framework can be a platform for a lot of


programming languages like Visual Basic, C++, and J#;
however, C# IS THE LANGUAGE CREATED FOR .NET
C++ VS C# (IMHO)
C++ C#
• Faster • OOP
• More Portable • Intellisense
• Huge .NET Framework
Library
• You always type and
type… #include<iostream>; • Arrays are objects
blah blah blah
THE TRANSITION
APPLICATIONS
DEVELOPED WITH C#
WEB APPLICATION
• Web Applications can be created using
the ASP.Net Technology
• Example: Facebook
• ASP.Net us a programming framework
that lets you create applications that run
on a Web sever and delivers
functionality through a web browser.
• Web applications uses web pages
WINDOWS
APPLICATION
• Windows applications are designed for
desktop use and for a single platform.
• Example: MS Word
• It includes GUI (Graphical User
Interface) which are basically menus,
buttons, pictures and other widgets.
• Can be done the hard or the easy way.
The Visual Studio provides both
options.
CONSOLE
APPLICATION
• Console applications normally send
requests to the OS to display text on the
command console display or to retrieve
data from the keyboard.
• Easiest to create
• Represent the simplest approach to
learning software development
• GUI – not a concern at all.
BASIC ELEMENTS OF
A C# PROGRAM
Using
Directives

Namespace

comments
Class

Main
Method

Method Body -
Statements
1. COMMENTS
• Writing a comment is like making notes for yourself or for
readers of your program.
• Not considered as instructions
• Have no effect on the running of the program
• 2 MAJOR FUNCTIONS
1. Makes code more readable
2. Internally document what program statements are doing
1. COMMENTS
• THREE TYPES OF
COMMENTS
1. In line comment
2. Multiline or Block
comment
3. XML Documentation
comment
2. USING DIRECTIVES
• This section lists the
namespaces that the
application will be using
frequently,
• It saves the programmer from
specifying a fully qualified
name every time that a
method that is contained
within is used.
3. NAMESPACES
• Namespace is a grouping of related types contained in an
assembly.
• For example, the System.Drawing namespace consists of
classes, methods that are grouped together to achieve
similar tasks.
• You can define your own namespace and indicate that
these are names associated with your particular
application.
4. CLASS DEFINITION
• Everything in C# is designed around a class.
• A class is the building block of an object oriented
program.
• C# doesn’t allow anything to be defined outside a class.
• Every program must have at least one class.
• There are predefined classes in the .NET Framework,
example is the Drawing class which is an abstract class
that describes a 2-D drawing.
• This particular class contains its own set of methods and
properties.
*SIMPLE OOP
SIMULATION
Namespace: A category or brand of cars. Note that the brand
really doesn't have to dictate how the car is built. You can't
say a Honda always have four doors, or that it always has
4wd. Such specifics is up to the class to dictate.
Class: Blueprint for how to build a specific car.
Object: An actual car (instance) created from the car
blueprint (the class)
Method: Something a user of the car can make it do. Start(),
IncreaseThrottle(), Break(), OpenDoor() etc.
Property: Attributes, information and building blocks which
the car contains. E.g. Total running miles, color, steering
wheel dimension, stereo system etc etc.
5. MAIN() METHOD
• It is the “entry point” for all applications.
• This is where the program begins execution.
• Can be placed anywhere inside a class definition.

• A method is a collection of one or more statements


combined to perform an action. AKA: functions,
subroutines, etc.
6. METHOD BODY
STATEMENTS
• Everything inside your method defines it.
• The Console class contains the standard input and output
methods for console applications:
• Console.Write()
• Console.WriteLine()
• Console.Read()
• Console.Readline()
ESCAPE SEQUENCES
• Backslash (\) is called the escape character.
• Combine it with one or more escape character and it
becomes a escape sequence.

Escape Sequence Description


Character
\n Next Line (Enter Key)
\t Tab
\” Displays a double quote
\’ Displays a single quote
\\ Displays a backslash
\r Current Line’s Beginning
\a Short Beep
END

Вам также может понравиться