Sei sulla pagina 1di 35

Points to be Discussed

What is C# Why use C# Evolution of C# Characteristics of C# Difference between C# and C++ Difference between C# and Java Variables Data Types Decision Making Looping

What is C#

What is C#?
C# (pronounced as C Sharp) is a computer

programming language developed by Microsoft Corporation, USA in June 2000. C# is a object-oriented language C# has been designed to support the key features of .NET Framework. C# is a modern language suitable for developing Web-based applications.

WHY Use c#

Why use C#?


A large number of computer languages, starting from FORTRAN developed in 1957 to the object-oriented language Java introduced in 1995, are being used for various applications. The choice of a language depends upon many factors such as hardware environment, business environment, user requirements and so on. Visual Basic could not meet some of the requirements of the WWW. Since VB is not a truly object-oriented language, it becomes increasingly difficult to use when systems become large.

Martin Richards

Ken Thompson

1967

BCPL

1970

1972 1983 1987 1991 1995 1996 2000

C C++ ANSI C Oak Java ANSI C++ C#

Dennis Ritche

Bjarne Stroustrup

ANSI Committee

James Gostling

Sun Microsystems

ANSI Committee

Microsoft

Why use C#?


Java, a language derived from C/C++ family, is a truly object-oriented language and has been used for creating a wide variety of web-based applications, still it does not support operator overloading. Microsoft wanted an environment that is completely in tune with the current and emerging Web-Programming practices and one that integrates with existing systems. The result is C#, a simple and modern language that directly addresses the needs of component-based software development.

EVOLUTION OF c#

Evolution of C#
To overcome the number of limitations in using the WWW over the Internet, Microsoft Chairman Bill Gates wanted to develop a software platform which would enable users to get information anytime and anywhere, using a natural interface. The platform must be a collection of readily available Web Services that can be distributed and accessed via standard internet protocols. The outcome was a new generation platform called .NET Microsoft introduced C# as the language of the .NET platform. C# has been particularly designed to build software components for .NET and it supports the key features of .NET.

characteristics of c#

Characteristics of C#
Simple

C# simplifies C++ by eliminating irksome operators such as ->,:: and pointers. Flexible C# does not support pointers, but we may declare certain classes and methods as unsafe and then use pointers to manipulate them. Modern It supports automatic garbage collection, modern approach to debugging, robust security model

Characteristics of C#
Object-Oriented

It supports Encapsulation, Inheritance, Polymorphism Type-Safe Type-Safety promotes robust programs. It supports automatic garbage collection. It enforces overflow checking in arithmetic operations Versionable Making new versions of software modules work with the existing applications is known as versioning

DIFFERENCE BETWEEN c# AND c++

Difference between C# and C++


The

first character of Main() function is Capitalized. The Main() must return either int or void type value C# does not support #include statement In C#, data types belong to either values types or reference types In C#, switch can also be used on string values C# can check overflow of arithmetic operations and conversions using checked and unchecked keywords

Difference between C# and C++


Arrays are classes in C#, and therefore, they

have built-in functionality for operations such as searching, sorting and reversing. C# does not support pointer types for manipulating data. However they are used in what is know as unsafe code. C# does not provide any defaults for constructors C++ allows multiple inheritance while C# does not.

Difference between C# and Java

Difference between C# and Java


Java uses static final to declare a class constant

while C# uses Const C# supports the struct type and Java does not Java does not provide for Operator Overloading Java does not have any equivalent to C# indexers In C#, switch can also be used on strings C# has the ability to alias namespaces

Difference between C# and Java


C# provides foreach for quick and easy iterations

over collections and array type data C# checks overflows using checked statements There is no labeled break statement in C#. The goto is used to achieved this C# has support for output parameters, aiding in the return of multiple values, a feature shared by C++ and SQL

Variables

Variables
A variable is an identifier that denotes a storage

location used to store a data value. A variable may take different values different values at different times during the execution the execution of the program. There are some rules for declaring variable names: 1. They must not begin with a digit 2. Uppercase and lowercase are distinct 3. It should not be a keyword 4. White space is not allowed 5. Variable names can be of any length

Data Types

Data Types
Every variable in C# has a data type. Data types

specify the size and type of values that can be stored. C# is rich in its data types. In C#, variables are the names of storage locations. After designing suitable variable names, we must declare them to the compiler. Declaration does three things: 1. It tells the compiler what the variable name is 2. It specifies what type of data it can hold 3. The place of declaration decides the scope of the variable

Data Types
The types in C# are divided into two types:

Value types 2. Reference types


1.

Value types and Reference types differ in two characteristics: 1. Where they are stored in the memory 2. How they behave in context of assignment statements

C# Data Types

Value Types

Pointer s

Reference Types

Pre Defined Types Integers Real Numbers Booleans Characters

User Defined Types

Pre Defined Types

User Defined Types

Enumeration s Structures

Objects Strings

Classes Arrays Delegates Interfaces

Simple Types

Boolea n Types

Numeri c Types

Characte r Types

Floatin g Point Types

Integral Types

Decima l Types

Signed Types

Unsigne d Types

Decision Making

Decision Making
IF Statement:

It tests a particular condition. Syntax if(condition checking expression) { Statement for true condition; }
If-else Statement: the else part gets executed if the

condition of if statement evaluates false.

Control Constructs
if(condition checking expression) { statement for true condition; } else { statement for false condition; }
If else-If statement:

1. It used to tests condition at multiple level. 2. Syntax:

Control Constructs
if(condition expression) { statement for true condition; } else if(condition expression) { statement for true condition of else-if ; } else if(condition expression) { statement for true condition of else-if ; } else { statement for false condition of all if; } Level1

Level2

Level3

Control Constructs
Nested If Statement: A nested if is an if that has another if in its ifs body or elses

body or both.
Syntax: if(condition expression) { if(expression){ Statement1;} else{ statement2;} } else{ if(expression){ Statement1;} else{ statement2;} }

Iteration/Loop Statement
Loop: used for repetition of same task.

Loop consists of three part: 1. Initialization exp: used to began loop , it executed only once. 2. Test/Condition exp: its truth value decides whether the loop body will be executed or not. 3. Update exp: It change the value of loop variable. It executed at the end of loop after the loop-body is executed. 4. The Body-of -the-loop: contains statement of loop

Types of Loop

for Loop while- Loop do-while Loop For- Loop: It initialize first, then test the condition, then execute statement from body of loop , and then execute update expression. Syntax: for(Initialization exp; Test exp; Update exp) { Body of loop Statements }

Nested-for-Loop
Syntax: for(Initialization exp; Test exp; Update exp) { Body of outer for loop for(Initialization exp; Test exp; Update exp) { Body of inner for loop Statements } }

While Loop
It tests the condition , then execute the statement

, and then execute update expression. Syntax:

while(test exp) { Statements Body of loop Update expression }

Do-while Loop
It executes the statements then executes update

expression, and then test the condition. It executes statements for one time false condition. Syntax: do { Statements Body of Loop Update expression } while(test expression);

Potrebbero piacerti anche