What is the difference between classes and structs in Microsoft.Net?
A struct is a value type, while a class is a reference type.
When we instantiate a class, memory will be allocated on the heap. When struct gets initiated, it gets memory on the stack.
Classes can have explicit parameter less constructors. But structs cannot have this.
Classes support inheritance. But there is no inheritance for structs. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Like classes, structures can implement interfaces.
We can assign null variable to class. But we cannot assign null to a struct variable, since structs are value type.
We can declare a destructor in class but can not in struct.
What is a Strong Name in Microsoft.Net?
In Microsoft.Net a strong name consists of the assembly's identity. The strong name guarantees the integrity of the assembly. Strong Name includes the name of the .net assembly, version number, culture identity, and a public key token. It is generated from an assembly file using the corresponding private key.
Steps to create strong named assembly:
To create a strong named assembly you need to have a key pair (public key and a private key) file. Use sn -k KeyFile.snk
Open the dot net project to be complied as a strong named assembly. Open AssembyInfo.cs/ AssembyInfo.vb file. Add the following lines to AssemblyInfo file.
[Assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("..\\..\\KeyFile.snk")]
Compile the application, we have created a strong named assembly.
What is the use of XSLT?
XSLT stands for Extensible Stylesheet Language Transformations. This language used in XSL style sheets to transform XML documents into other XML documents.
XSLT is based on template rules which specify how XML documents should be processed. An XSLT processor reads both an XML document and an XSLT style sheet. Based on the instructions the processor finds in the XSLT style sheet, it produce a new XML document. With XSLT we can also produce HTML or XHTML from XML document. With XSLT we can add/remove elements and attributes, rearrange and sort elements, hide and display elements from the output file. Converting XML to HTML for display is probably the most common application of XSLT today.
Explain ACID properties of the database?
All Database systems which include transaction support implement ACID properties to ensure the integrity of the database. ACID stands for Atomicity, Consistency, Isolation and Durability
Atomicity: Each transaction is said to be “atomic.” If one part of the transaction fails, the entire transaction fails. Modifications on the data in the database either fail or succeed.
Consistency: This property ensures that only valid data will be written to the database. If, for some reason, a transaction is executed that violates the database’s consistency rules, the entire transaction will be rolled back and the database will be restored to a state consistent with those rules.
Isolation: It requires that multiple transactions occurring at the same time not impact each other’s execution.
Durability: It ensures that any transaction committed to the database will not be lost.
What is the basic functionality of Garbage Collector in Microsft.Net?
The Common Language Runtime (CLR) requires that you create objects in the managed heap, but you do not have to bother with cleaning up the memory once the object goes out of the scope or is no longer needed. The Microsoft .NET Framework Garbage Collector provides memory management capabilities for managed resources. The Garbage Collector frees objects that are not referenced and reclaims their memory. You should set your references to Nothing(null) as soon as you are done with them to ensure your objects are eligible for collection as soon as possible.
Here are the list of some tasks performed by the Garbage collector:
Garbage collector reserves a piece of memory as the application starts for the managed heap.
Garbage collector controls the managed heap memory currently used and available to an application.
Garbage collector allocates memory for new objects within the application.
The Garbage Collector attempts to reclaim the memory of objects that are not referenced.
What is a static class?
We can declare a static class. We use static class when there is no data or behavior in the class that depends on object identity. A static class can have only static members. We can not create instances of a static class using the new keyword. .NET Framework common language runtime (CLR) loads Static classes automatically when the program or namespace containing the class is loaded.
Here are some more features of static class
Static classes only contain static members.
Static classes can not be instantiated. They cannot contain Instance Constructors
Static classes are sealed.
What is static member of class?
A static member belongs to the class rather than to the instances of the class. In C# data fields, member functions, properties and events can be declared static. When any instances of the class are created, they cannot be used to access the static member.
To access a static class member, use the name of the class instead of an instance variable
Static methods and Static properties can only access static fields and static events.
Like: int i = Car.GetWheels;
Here Car is class name and GetWheels is static property.
Static members are often used to represent data or calculations that do not change in response to object state.
What is the purpose of Server.MapPath method in Asp.Net?
In Asp.Net Server.MapPath method maps the specified relative or virtual path to the corresponding physical path on the server. Server.MapPath takes a path as a parameter and returns the physical location on the hard drive. Syntax
Suppose your Text files are located at D:\project\MyProject\Files\TextFiles
If the root project directory is MyProject and the aspx file is located at root then to get the same path use code
//Physical path of TextFiles
string TextFilePath=Server.MapPath("Files/TextFiles");
No comments:
Post a Comment