Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

C# Chapter 1

Q. What is .NET Framework?

Q. Define the .NET Architecture.

Ans:- The .NET Framework is a platform developed by Microsoft Corporation. The first version of .NET Framework was 1.0 launched by Microsoft in year 2000. The .NET Framework provide the platform to build the different kind of applications such as Console Applications, Windows Applications, Web Application, Web Services, Mobile Applications etc. There are basically 3 parts of .NET Framework


CLR(Common Language Runtime) is the heart and soul of .NET Framework. It perform the number of task for applications developed in .NET Framework. It is the layer of .NET Framework which is reside between Operating System and .NET Application. It handle the execution of all .NET Applications. Programs developed in .NET don’t  directly communicate with the OS but go through the CLR.

The CLR provide the number of services for application runs under .NET Framework, describe below:-

  1. CLR provides the memory isolation or protection for programs. It protects the one program to overwrite on another program. It perform san important task for memory management called garbage collection.
  2. The program developed under .NET Framework load and execute in the control of CLR.
  3. .NET provides the feature of type safety which is perform by CLR.
  4. When a program executes any error or exception can be arise, which are handled by CLR.
  5. The task of debugging is also perform with the help of CLR.
  6. The MSIL (Microsoft Intermediate Language) code is converts into native (Execution Code) code by CLR.
  7. CLR provide the metadata (data about data).

These are the some list of common services and functions perform by CLR.

CTS (Common Type System)

It is the feature of CLR which enable the different language can run under the control of .NET Framework. The CTS supports a variety of types and operations found in most programming languages and that’s why we don’t need of type conversion of Data Types from one .NET Language to another .NET Language, for e.g. we can use the code of  VB into C# without any type conversion.

CLS (Common Language Specification)

The CLS defines a set of rules that enables interoperability on the .NET Platform. These rules define a guide to third-party compiler designers and library builders. CLS is a subset of CTS and therefore the languages supporting the CLS can use each other’s class libraries. APIs (Application Program Interfaces) that are designed under the CLS rules can be used by all .NET Languages.

MSIL (Microsoft Intermediate Language)

MSIL is also known as IL (Intermediate Language), is an instruction set into which all the .NET programs are compiled. The all languages which support the .NET Framework generate the MSIL code after compilation, which goes to CLR and generate the Native Code. It is like the assembly language which contains instructions for loading, storing, initializing and calling methods.

Framework Base Classes

To build the application fast and without errors .NET Framework provide a library of base classes. We can use them by simply instantiating them and invoking their methods or by inheriting them through derived classes, thus extending their functionality. Most of the framework classes in the vast namespace called System.

Q. Define the differences between C# and C++.
Q. What are the differences between C# and C++?
Q. How does C# differ from C++?

Ans. C# is evolved from C and C++. So, some features of C# and C++ are matched. But C# has the number of additional features which make it very modern language as compare C++, some main difference between C# and C++ are given below:-

  1. The Main( ) function has the first letter capital in C#. It return either int or void type value. But in C++ main( ) function has all small letters.
  2. In C# when class is define it does not use a semicolon at the end, but in C++ a semicolon is always use at the end of class definition.
  3. In C# using is use instead of #include.
  4. C# compiler not generates the object file after compilation, but C++ compiler generates the object file after compilation of program.
  5. All data types in C# are inherited from the object super class and therefore they are objects.
  6. The data types of C# either belong to value type or reference type.
  7. C# is suitable to build distributed applications because it’s basic data type has the same size on all machines.
  8. In C# structs are value types.
  9. C# generate the error at compile time, if we use the uninitialized variable in program. But C++ is not able to detect uninitialized variables at compile time.
  10. C# does not support ‘pointers’ but it is use ‘unsafe’ code.
  11. In C# objects are crated with the help of ‘new’ keyword.
  12. Array is the class in C# therefore there are in-build function for sorting, searching and reverse the Array. The declaration and behavior of Array is totally different in C#.
  13. In C# switch also work on string value. But in C++ switch doesn’t work on string values.
  14. C# does not support the default argument.
  15. C# can check overflow of arithmetic operations and conversions using checked  and unchecked keywords.
  16. C# does not provide any defaults for constructor.
  17. Static members can not be accessed through object of class, but in C++ we can access the static member through class object.
  18. Behavior of destructor in C# is totally different than C++.
  19. C# does not support multiple inheritance.
  20. In C# when overriding a virtual method, we must use the override keyword.
  21. Abstract methods in C# are similar to virtual functions in C++ but C# abstract methods cannot have implementations.
  22. Casting of data in C# much safer as compare C++.
Q. Define the differences between C# and Java.
Q. What are the differences between C# and Java?
Q. How does C# differ from Java?

Ans. C# and Java both are very popular language for programming. Both are derived from C++. Java is developed by Sun Microsystem and C# is developed by Microsoft as an alternate of Java for web programming. In both of languages developers are able to build Console Application, Windows Applications, Web Application and Services. But there are number of differences between these languages given below:-

  1. In C# are data types are treated as object, but in Java it is not.
  2. The declaration, using and behavior of Arrays are totally different in C# as compare Java.
  3. To declare a class constant C# use const keyword but Java use static final.
  4. There is no labeled break statement in C#. The goto is used to achieve this.
  5. In C# we can use the variable number of parameters by using params keyword.
  6. C# uses is operator instead of instanceof operator in Java.
  7. Catch blocks should be ordered correctly in C#.
  8. C# supports the struct type but Java not.
  9. In C# the base member is required to have the virtual keyword and the derived member is required to use the override keyword. But in Java class members are virtual by default and a method having the same name in a derived class overrides the base class members.
  10. C# support better versioning as compare Java.
  11. The new modifier used for class members has no complement in Java.
  12. C# provides static constructors for initialization.
  13. C# provides built-in delegates and events. Java uses interfaces and inner classes to achieve a similar result.
  14. In Java parameters are always passed by value. But in C# we can pass the parameters by reference also by using ref keyword.
  15. internal is a new access modifier in C#. The members declared internal can be accessed from other classes within the same project, but not from outside the project.
  16. Java has no equivalent of indexers of C#.
  17. C# supports the enumerators but Java not supports enumerations directly.
  18. C# includes native support for properties, Java does not.
  19. C# includes native support for properties, Java does not.
  20. C# does not allow free fall_through from case to case.
  21. Both Java and C# supports the interfaces. But C# does not allow type definitions in interfaces, while Java interfaces can have const (constant) type data.
  22. foreach is a new loop used in C# which work on collection of data.
  23. In Java the switch statement can have only integer expression, while C# supports either an integer or string expressions.

Q. Define the characteristics of C#.
Q. What is C#?
Q. Enumerate the benefits and limitations of .NET technology.

Ans. C# is a modern language which is derived from C and C++. C# is a fully object oriented language like java and it is the first component oriented language. It is the only language which is designed to support .NET Framework. It consist the is features of C, C++, Java and VB. It is most powerful, flexible and easy to read – write and maintain. The most common and important characteristics of C# are listed below. It is develop by Microsoft Corporation Team lead by Anders Hejlsberg :-

 Simple and Modern
C# is much simple and modern language because it support the number of new features such as
  • Automatic garbage Collection.
  • Rich intrinsic model for error handling.
  • Modern approach for debugging and compiling.
  • Robust security model.
  • Decimal data type for financial applications.

Type safe
C# is a type safety language due to many reasons such as
  • If we use the uninitialized variable it is caught by compiler
  • It not allows the user to unsafe type casts.
  • The arrays and dynamically allocated objects are initialized to zero.
  • If we access the array out of bound compiler caught it.
  • C# enforces overflow checking in arithmetic operations.
  • C# provides the automatic garbage collection.
  • Reference parameters that are passed are type safe.

C# is truly object oriented language, because it support the Encapsulation, Inheritance and Polymorphism. There are no global variable, functions and constants, everything is an object. The class model of C# is built on top of the virtual Object system (VOS) of the .NET Framework.

C# supports an unified type system which eliminates the problem of varying ranges of integer data type. All types are treated as objects and developers can extend the type system simply and very easily.

Versioning means that build a new software module work with existing application/software. In C# by using the new and override keyword programmer can build a new version software module of existing application, these keywords ensure that new class library will maintain binary compatibility with the existing application/software.

C# is a language which supports the CLS (Common Language Specification), which work under the .NET Framework, therefore the C# allows inter-operation with other language which support the .NET Framework.

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.

C# is a flexible language in nature, as we know that C# not support the pointer but by using unsafe we can the pointers for manipulation. But these codes are not type-safe, therefore it is known as unsafe.


The Managed Code of .NET Applications affects the system performance. The fact that managed applications are run by the .NET Framework is obviously going to affect performance because it will put extra overhead on CPU. The performance loss is going to vary considerably according to precisely what an application is doing, but in general at present you can typically expect a 5-10% increase in CPU time to perform a given task.

One more limitation with .Net Technology is that programmer must have to learn about .NET and concept of OOP before works with C#. If a programmer is excellent in VB6.0 but he/she doesn’t know about OOP then it is very typical that he/she build an application in .NET.

No comments:

Post a Comment