NET Subject Code: BSIT - 61 Assignment TA (Compulsory ) 1) What does .NET framework comprised off?
Ans :- Microsoft has developed .NET Framework. .NET Framework is comprised of programming methodologies like Visual Studio.NET and Mixed language programming, Platform technologies like ADO.NET, Windows Form, etc and Code Execution environment. The .Net framework has integrated few main languages and other existing technologies within it. They are C, C++, J++, VB.NET, ASP.NET, Scripting Languages- JScript.NET, ADO.NET, COM and COM+. The advantages of .NET Framework are: Provides Consistent Programming Model Has Language Independence No versioning Problem - Easy Application Deployment and Maintenance Improved Security Support for Web Services Dynamic Web facilities Full fledged Visual Studio.NET
2) Which are the platform technologies supported by .NET framework? Ans :- The .Net framework has integrated few main languages and other existing
technologies within it. They are C, C++, J++, VB.NET, ASP.NET, Scripting LanguagesJScript.NET, ADO.NET, COM and COM+. ASP.NET :-ASP is upgraded to ASP.NET on .Net Framework. The coding can be done directly in any of C#, VB.NET or JScript.NET. The code is compiled into classes which respond to the web requests. Because of backward compatibility the ASP code still continues to run on this new platform. COM and COM+ :-The COM+ remains as an important tool in .NET. COM works on .NET because of backward compatibility. Now on .NET Framework, calling and managing the components has become easy because .NET incorporates the COM interoperability feature. J++ :-No updating are made to this language. It is supported on .Net only for backward compatibility. There is much similarity between the J++ and C# syntax, So a tool which converts the J++ code to C# code is provided by .NET. Using this tool we can use convert J++ application to C# and use the facilities provided to C# language.
4.)What is the function of CTS? Explain the classification of types in CTS with a diagram.
Ans :- Common Type System (CTS):- This is a standardized agreed set of basic data types. This system provides a way for language interoperability. Language Interoperability means that a object implemented in one language can call a object implemented in another language. In more general way you can say that a application can be developed in two or more languages supported by .Net framework. To make use of language interoperability feature, the developers have to follow CTS. Classification of types The CTS supports two categories:1. Value types:- Value types directly stores data in the variable. Value types can be built-in type, user-defined types, or enumerations. 2. Reference types:- Reference types store a reference to the datas 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.
enum Enum1 { } namespace Namespace2 { } class Class2 { public static void Main(string[] args) { } } }
{ static void F() { System.Console.WriteLine(Test.F); } static void Main() { SimpleDelegate dele = new SimpleDelegate(F); dele(); } }
Ans :- C# is an imperative language, but like all imperative languages it does have some declarative elements. For example, the accessibility of a method in a class is specified by declaring it public, protected, internal, protected internal, or private. C# generalizes this
capability, so that programmers can invent new kinds of declarative information, attach this declarative information to various program entities, and retrieve this declarative information at run-time. Programs specify this additional declarative information by defining and using attributes. For instance, a framework might define a Help Attribute that can be placed on program elements (such as classes and methods) enabling developers to provide a mapping from program elements to help documentation for them. The example using System; public class HelpAttribute: Attribute { public HelpAttribute(string url) { this.url = url; } public string Topic = null; private string url; public string Url { get { return url; } } }
Assignment: TB (Compulsory) 1.What are events? Give an example to demonstrate its usage.
Ans :- An event is a member that enables an object or class to provide notifications. A class defines an event by providing an event declaration and an optional set of event assessors. The declaration resembles a field declaration, though with an added event keyword. The type of this declaration must be a delegate type. An instance of a delegate type encapsulates one or more callable entities. For instance methods, a callable entity consists of an instance and a method on that instance. For static methods, a callable entity consists of just a method. Given a delegate instance and an appropriate set of arguments, one can invoke all of that delegate instances methods with that set of arguments. For example:public delegate void EventHandler(object sender, System.EventArgs e); public class Button { public event EventHandler Click; public void Reset() { Click = null; } }
That is, class Stack is implemented as a linked list, but it also provides the convenience of array access. Indexer declarations are similar to property declarations, with the main differences being that indexers are nameless and that indexers include indexing parameters. The indexing parameters are provided between square brackets.
4.What are the different methods supported by system. Object class? Give an example for each.
Ans :- System. Object class is the ultimate base class that all types directly or indirectly derive from. The object class allows us to build generic routines, provides Type System Unification, and enables working with groups collections. The object class also facilitates using any type in a collection. It contains methods that can be reused or overridden in base types. Since collections,
such as Hashtable and ArrayList accept object types, we can add any type to them. The Equals, GetType, and GetHashCode object class methods are called directly by the collection classes. The Equals Method:- The Equals method of the object class provides a default implementation that compares two reference type objects for reference equality. For example using System; class Employee { string e_name; public Employee(string name) { e_name = name; } } class EqualsDemonstration { static void Main() { EqualsDemonstration eqDemo = new EqualsDemonstration(); eqDemo.InstanceEqual(); Console.ReadLine(); } public void InstanceEqual() { string name = Joe; Employee employee1 = new Employee(name); Employee employee2 = new Employee(name); // comparing references of separate instances bool isEqual = employee1.Equals(employee2); Console.WriteLine(employee1 == employee2 - {0}, isEqual); employee2 = employee1; // comparing references of the same instance isEqual = employee1.Equals(employee2); Console.WriteLine(employee1 == employee2 - {0}, isEqual);} } The ToString Method:- The purpose of the ToString method is to return a string representation of a type. The default implementation in the object class returns a string with the name of the object. For example using System; class Employee { string e_name; public Employee(string name) { e_name = name; } // If ToString() is not overridden, the output of this program will be Employee. public override string ToString() { return String.Format([Employee: {0}], e_name); } } class ToStringDemonstration { static void Main() { Employee emp = new Employee(Joe); Console.WriteLine(emp.ToString()); Console.ReadLine(); } } The Finalize Method:- the Finalize method as a destructor. The original purpose of the destructor was to serve as a place where we can release unmanaged resources such as network connections, operating system resources, or file streams. However, in practice we never want to use the destructor. The reason is that a destructor is executed automatically by the garbage collector. For example using System; class Employee { string e_name; public Employee(string name)
{ e_name = name; Console.WriteLine(Employee Name: {0}, e_name); } ~Employee() { Console.WriteLine(Employee destructor executed.); } } class DestructorDemonstration { static void Main(){ Employee emp = new Employee(Joe); } } The GetType Method:- GetType is the basis for using reflection in .NET. It returns a Type object, describing the object it was called on. It can then be used to extract type member data like methods and fields that may subsequently be used for late-bound method invocations. For example using System; class Employee { } class GetTypeDemonstration { static void Main() { object emp1 = new Employee(); Employee emp2 = new Employee(); Console.WriteLine(emp1.GetType()); Console.WriteLine(emp2.GetType()); Console.ReadLine(); } }
What is the use of System Collection class? Ans :- The System. Collections namespace contains interfaces and classes that define various
collections of objects, such as lists, queues, bit arrays, hash tables and dictionaries. Each class has a set of methods and properties, which are used on those corresponding class objects.
What is data provider? Explain. Ans :- A .NET data provider is used for connecting to a database, executing commands, and
retrieving results. Those results are either processed directly, or placed in an ADO.NET Dataset.
The .NET data provider is designed to be lightweight, creating a minimal layer between the data source and application code, increasing performance without sacrificing functionality.
What is a data set? Explain. Ans :What is the role of System.web? Ans :Write a program to demonstrate handling of server control events. Ans :-