C# is an object-oriented programming language developed by Microsoft that is similar to C++ but simplified. It can be used to create a variety of applications including Windows forms, web applications, web services, and .NET components. Some key features of C# include being type-safe, object-oriented, and compatible with other .NET languages. It also provides modern features like automatic memory management and support for error handling. C# aims to combine the best aspects of languages like C++, Java, and Visual Basic.
SQL Database Design For Developers at php[tek] 2024
What is C#? An introduction to the programming language
1. By: Shehrevar Davierwala 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 controls
- Providing Web services
- Developing .NET component library
2. By: Shehrevar Davierwala 2
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 an 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.
– Encapsulation
- Inheritance
- 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 are 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
3. By: Shehrevar Davierwala 3
- 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.
How does C# differ from C++?
1. C# compiles straight from source code to executable code, with no object files.
2. C# does not separate class definition from implementation.
3. In C#, class definition does not use a semicolon at the end.
4. the first character of the Main() function is capitalized. The Main must return either int or
void type value.
5. C# does not support #include statement.
6. All data types in C# are inherited from the object super class and therefore they are
objects.
7. all the basic value types will have the same size on any system.
8. In C#, data types belong to either value types or reference types.
9. C# checks for uninitialized variables and gives error messages at compile time.
10.In c#, structs are value types.
11.C# declares null as a keyword and considers it as an intrinsic value.
12.C# permits declaration of variables between goto and label.
13.C# does not support default arguments
4. By: Shehrevar Davierwala 4
C++ features dropped
a. Macros
b. Multiple Inheritance
c. Templates
d. Pointers
e. Global variables
f. Typedef statement
g. Default arguments
h. Constant member functions or parameters
i. 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
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.
5. By: Shehrevar Davierwala 5
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.