Introducing C

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

1.

Introducing C#
1. What is C#?
C# is a new computer-programming language developed by Microsoft
Corporation, USA.
C# is a fully object-oriented language like Java and is the first Component-
oriented language.
It has been designed to support the key features of .NET Framework.
It is simple, efficient, productive and type-safe language derived from the
popular C and C++ languages.
C# is designed for building robust, reliable and durable components to
handle real-world applications.
Major highlights of C# are :
- It is a brand new language derived from the C/C++ family
- It simplifies and modernizes C++
- It is the only component-oriented language available today
- It is the only language designed for the .NET framework
- It is a concise, lean and modern language
- It combines the best features of many commonly used languages:
The productivity of Visual Basic, the power of C++ and the elegance
of Java
- It is intrinsically object- oriented and web-enabled
- It has a lean and consistent syntax
- It embodies today’s concern for simplicity, productivity and
robustness
- It will become the language of choice for .NET programming
-Major parts of .NET Framework are actually coded in C#

Applications of C#

Console applications, Windows applications, Developing Windows controls,


Developing ASP.NET projects, Creating Web control, Providing Web services,
Developing.NET component library.
Characteristics of C#

The main design goal of C# was simplicity rather than pure power. C# fulfills the
need for a language that is easy to write, read and maintain and also provides the
power and flexibility of C++.

The language that is designed for both computing & communications is


characterized by several key features:

Simple: C# simplifies C++ by eliminating operators such as ->, :: and pointers. C#


treats integer and Boolean data types as two entirely different types. This means
that the use of = in place of == in if statement will be caught by the compiler.

Consistent: C# supports a unified type system which eliminates the problem of


varying ranges of integer types. All types are treated as objects and developers
can extend the type system simply and easily.

Modern: C# is called a modern language due to a number of features it supports.


It supports: -Automatic garbage collection

-Rich intrinsic model for error handling

-Decimal data type for financial applications

-Modern approach to debugging and

-Robust security model

Object-Oriented: C# is truly object-oriented. It supports all the three tenets of


object-oriented systems.

A) Encapsulation B) Inheritance C) Polymorphism

The entire C# class model is built on top of the Virtual Object System of the .NET
framework. In C#, everything is an object. There are no more global functions,
variables and constants.

Type-Safe: Type-safe promotes robust programs. C# incorporates a number of


type-safe measures.
- All dynamically allocated objects and arrays are initialized to zero

- Use of any uninitialized variables produces an error message by the compiler


- Access to arrays is range-checked and warned if it goes out-of-bounds

- C# does not permit unsafe casts

- C# enforces overflow checking in arithmetic operations

- Reference parameters that are passed are type-safe

- C# supports automatic garbage collection

Versionable: Making new versions of software modules work with the existing
applications is known as versioning. C# provides support for versioning with the
help of new and override keywords. With this support, a programmer can
guarantee that his new class library will maintain binary compatibility with the
existing client applications.

Compatible: C# enforces the .NET common language specifications and therefore


allows inter-operation with other .NET languages.

- C# provides support for transparent access to standard COM and OLE


Automation.

- C# also permits interpolation with C-style APIs.

Flexible: Although C# does not support pointers, we may declare certain classes
and methods as ‘unsafe’ and then use pointers to manipulate them. However,
these codes will not be type-safe.

Inter-operability: C# provides support for using COM objects, no matter what


language was used to author them. C# also supports a special feature that
enables a program to call out any native API.
2. How does C# differ from C++?

a) C# compiles straight from source code to executable code, with no object


files.

b) C# does not separate class definition from implementation.

c) In C#, class definition does not use a semicolon at the end.

d) The first character of the Main() function is capitalized. The Main must return
either int or void type value.

e) C# does not support #include statement.

f) All data types in C# are inherited from the object super class and therefore
they are objects.

g) All the basic value types will have the same size on any system.

h) In C#, data types belong to either value types or reference types.

i) C# checks for uninitialized variables and gives error messages at compile time.

j) In c#, structs are value types.

k) C# declares null as a keyword and considers it as an intrinsic value.

l) C# permits declaration of variables between goto and label.

m) C# does not support default arguments.

C++ features dropped

1. Macros

2. Multiple Inheritance

3. Templates

4. Pointers

5. Global variables
6. Typedef statement

7. Default arguments

8. Constant member functions or parameters

9. Forward declaration of classes

Enhancements to C++:

1. Automatic garbage collection

2. Versioning support

3. Strict type-safety

4. Properties to access data members

5. Delegates and events

6. Boxing and unboxing

7. Web services

3. How does C# Differ from Java?

1) C# compiler produces an executable code.

2) C# has more primitive data types.

3) Unlike java , all C# data types are objects.

4) Arrays are declared differently in C#.

5) Java uses static final to declare a class constant while C# uses const.

6) C# supports the struct type and Java does not.

7) Java does not provide for operator overloading.

8) The new modifier used for class members has no complement in Java.
9) C# provides better versioning support than Java.

10) C# provides static constructors for initialization.

11) C# includes native support for properties, Java does not.

12) Java does not directly support enumerations.

13) C# checks overflows using checked statements.

14) C# uses is operator instead of intanceof operator in Java.

15) C# allows a variable number of parameters using the params keyword.

You might also like