Pages

Thursday, September 12, 2013

Guide to advantages of .Net Framework

1.        What are the advantages of using .NET ?
Consistent Programming Model:
Different programming languages have different approaches for doing a task. For example, accessing data with a VB application and a VC++ application is totally different. A developer has to know bothdifferent techniques to do the task. In case of .NET Environment, for the same example, displaying data from database in a grid accessing data with a VB.NET and a C# is very similar except slight syntactical differences. Both the programs use the System.Data namespace, establish a connection with the database and run a query and displays the data on a data grid.

Language Independence:
Language Independence means the developer has the independence to code one module of an application in one language and other module of same application in other language. This language interoperability can help in code reuse and improve the efficiency of the development process.

No versioning Problem - Easy Application Deployment and Maintenance:
The .NET Framework makes deployment of applications easy. Commonly, to install an application all we need to do is, copy the application along with the components it requires into a directory on the computer. The .NET handles the details of locating and loading the components an application needs, even if several versions of the same application exist on the computer. The .NET ensures that all the components the application depends on are available on the computer before the application begins to run.

Improved Security:
The .NET Framework provides several mechanisms for protecting resources and code from unauthorized users:
·            ASP.NET Web Application Security provides a way to control access to a web site by comparing authenticated permissions with File System permissions for proper authorization.
·            Code access security uses permissions to control the code accessing protected resources and operations. The computer systems are protected from suspicious mobile code and provide a way to run mobile code to safely.
·            Role-based security provides information needed to make decisions about user’s permissions.

Support for Web Services:
Web services are remote databases and programs, which access other computers to read the data files. Web services provide many built in Base Class library facilities which open up a whole new world of information for users.

Dynamic Web:
Content that changes with the user and user preferences is an example of dynamic web content. Dynamic web content is easier to create with .NET. ASP.NET and Visual Studio.NET allow developers to create dynamic web much easier than IIS and ASP technologies.

Visual Studio.NET:

Visual Studio.NET is the Microsoft application and interface for programming in .NET. Visual Studio .NET provides all the programming advantages mentioned so far. This development environment has extensive set of ready to use controls, good debugging facilities, easy and simple programming features and vast set of .NET Base Classes.


1.        Explain different features of .NET.

2.        What is .NET ?
List the advantage of .NET frame work.

Consistent Programming Model:
Different programming languages have different approaches for doing a task. For example, accessing data with a VB application and a VC++ application is totally different. A developer has to know bothdifferent techniques to do the task. In case of .NET Environment, for the same example, displaying data from database in a grid accessing data with a VB.NET and a C# is very similar except slight syntactical differences. Both the programs use the System.Data namespace, establish a connection with the database and run a query and displays the data on a data grid.

Language Independence:
Language Independence means the developer has the independence to code one module of an application in one language and other module of same application in other language. This language interoperability can help in code reuse and improve the efficiency of the development process.

No versioning Problem - Easy Application Deployment and Maintenance:
The .NET Framework makes deployment of applications easy. Commonly, to install an application all we need to do is, copy the application along with the components it requires into a directory on the computer. The .NET handles the details of locating and loading the components an application needs, even if several versions of the same application exist on the computer. The .NET ensures that all the components the application depends on are available on the computer before the application begins to run.

Improved Security:
The .NET Framework provides several mechanisms for protecting resources and code from unauthorized users:
ASP.NET Web Application Security provides a way to control access to a web site by comparing authenticated permissions with File System permissions for proper authorization
·             Code access security uses permissions to control the code accessing protected resources and operations. The computer systems are protected from suspicious mobile code and provide a way to run mobile code to safely.
·             Role-based security provides information needed to make decisions about user’s permissions.

Support for Web Services:
Web services are remote databases and programs, which access other computers to read the data files. Web services provide many built in Base Class library facilities which open up a whole new world of information for users.

Dynamic Web:
Content that changes with the user and user preferences is an example of dynamic web content. Dynamic web content is easier to create with .NET. ASP.NET and Visual Studio.NET allow developers to create dynamic web much easier than IIS and ASP technologies.

Visual Studio.NET:

Visual Studio.NET is the Microsoft application and interface for programming in .NET. Visual Studio .NET provides all the programming advantages mentioned so far. This development environment has extensive set of ready to use controls, good debugging facilities, easy and simple programming features and vast set of .NET Base Classes.

1.        Explain .NET framework?
The .NET Framework is the foundation on which you can design, develop, and deploy applications. It is the core of the .NET infrastructure. It exists as a layer between the .NET applications and the underlying operating system. The .NET Framework encapsulates much of the basic functionality, such as debugging and security services, which was earlier built into various programming languages.

2.        What is unsafe code? Explain.

Unsafe code refers to the code that is processed with low security levels. There are situations where access to pointer types becomes a necessity. For example, interfacing with the underlying operating system, accessing a memory-mapped device, or implementing a time-critical algorithm may not be possible without access to pointers. To address this need, C# provides the ability to write unsafe code. In unsafe code, it is possible to declare and operate on pointers, to perform conversions between pointers and integral types, to take the address of variables, and so forth. In a sense, it is like writing C code within a C# program. Unsafe code must be clearly marked with the modifier unsafe, so developers cannot possibly use unsafe features accidentally. When CLR finds this unsafe modifier, the execution engine works to ensure that the unsafe code cannot be executed in an untrusted environment.

3.        Explain the following:

b) JIT compiler.
JIT compilation converts IL into its native machine code. The name JIT is because it compiles portion of code as and when required at runtime.



4.        How .NET remoting different from web services and DCOM ?
The differences between .NET Remoting and Web services are listed as follows:
·             ASP.NET based Web services can only be accessed over HTTP, whereas the .NET Remoting can be used across any protocol.
·             Web services work in a stateless environment where each request results in a new object created to service the request. .NET Remoting supports state management options and can identify multiple calls from the same client.
·             Web services serialize objects through XML contained in the SOAP messages and can thus only handle items that can be fully expressed in XML. .NET Remoting relies on the existence of the metadata within assemblies that contain information about data types. This limited metadata information is passed about an object, when it is passed by reference.
·             Web services support interoperability across platforms and are good for heterogeneous environments. .NET Remoting requires the clients to be by built using .NET, which means a homogeneous environment.
The difference between .NET Remoting and DCOM is listed as follows:
·             DCOM relies on a proprietary binary protocol that not all object models support. It also wants to communicate over a range of ports that are typically blocked by firewalls. However, .NET Remoting supports different transport protocol formats and communication protocols. This allows .NET Remoting to be adaptable to the network environment in which it is being used.
1.        Write a program in C# to display “Welcome to C Sharp”. Explain the program.
The C# program is as follows:
using System;
namespace ConsoleApplication1
{
class Welcome
{
                             static void Main()
                             {
                             System.Console.WriteLine("Welcome to C Sharp");
                             Console.Read();
}
}
}

The important points to be noted in this program are:
·             Main method: Program execution begins with the Main method.
·             Input and output: The WriteLine function displays the string on the standard output device.
·             Compilation and execution: To compile the program, enter the following command:
cscWelcome.cs
To execute the program, enter the following command:
Welcome

2.        How does C# supports multiple inheritance?
C# directly does not support multiple inheritance. But we can use this feature by using interface. Interface supports multiple inheritance.
interfaceIControl
{
void Paint();
}

interfaceITextBox: IControl //ITextBox inherits IControl
{
voidSetText(string text);
}

interfaceIListBox: IControl //IListBox inherits IControl
{
voidSetItems(string[] items);
}

interfaceIComboBox: ITextBox, IListBox {}
the interface IComboBox inherits from both ITextBox and IListBox. Classes and structs can implementmultiple interfaces.
1.        Define the following :
CLR, CTS, CLS, Intermediate language.
CLR:The CLR loads and executes the code. Code management is a fundamental principle of the runtime. It also provides services such as memory management, thread management, remoting, type safety, code security, and robustness.
CTS:The CTS is a standardized set of basic data types. This system provides a way to language interoperability. An object implemented in one .NET supported language can call an object implemented in another .NET supported language.
CLS: Common Language Specification (CLS) is a set of rules for basic language features that have been defined to enhance and ensure language interoperability.




2.        Give the classification of comman data type system.

3.        What is the function of CTS ? Explain the classification of types in CTS with a diagram.
The CTS defines how types are declared, used, and managed in the runtime. It is important for language interoperability. The CTS performs the following functions:
·             Establishes a common framework that enables cross-language integration, type safety, and high performance code execution.
·             Provides an object-oriented model.
·             Defines rules that languages must follow, so that different languages can interact with each other
CTS can be classified into:
·             Value types
·             Reference types
The following diagram illustrates type classification.
Value types directly store data in the variable. Value types can be built-in type, user-defined types, or enumerations.
Reference types store a reference to the data's memory address. Reference types can be self-describing types, pointer types, or interface types. Self-describing types are further split into arrays and class types. The class types are user-defined classes, boxed value types, and delegates.
All types derive from the System.Object base type


4.        What is operator overloading? Explain with an example.
Operator overloading refers to loading an operator to perform different operations on different data types on different contexts. To overload an operator in a class, one defines a method by using the 'operator' keyword.
The following program uses operator overloading to create a complex number class ComplexAdd that defines complex addition. The program displays the imaginary and the real parts of the numbers and the addition result using an override of the ToString method.
// complexAdd.cs
using System;
public struct ComplexAdd
{
public int r;
public int img;
public Complex(int r, int img)
   {
      this.r = r;
      this.img = img;
   }
   // Declare which operator to overload
public static ComplexAdd operator +(ComplexAdd c1, ComplexAdd c2)
   {
return new ComplexAdd(c1.r + c2.r, c1.img + c2.img);}
   // Override the ToString method to display a complex number in a required format:
public override string ToString()
   {
return(String.Format("{0} + {1}i", r, img));}
public static void Main()
   {
      ComplexAdd var1 = new ComplexAdd(5,3);
      Complex var2 = new Complex(6,2);
      // Add two Complex objects (var1 and var2) through the
      // overloaded plus operator:
      ComplexAdd total = var1 + var2;
     // Print the numbers and the sum using the overridden ToString method:
Console.WriteLine("First complex number:  {0}",var1);
Console.WriteLine("Second complex number: {0}",var2);
Console.WriteLine("The sum of the two numbers: {0}",total);}}
Output
First complex number: 5 + 3i
Second complex number: 6 + 2i
The sum of the two numbers: 11 + 5i 

No comments:

Post a Comment