Q-What
is the difference between Finalize() and Dispose()?
Finalize
()
is called by Garbage Collector implicitly to free unmanaged resources. The
garbage collector calls this method at some point after there are no longer
valid references to the object. There are some resources like windows handles,
database connections which cannot be collected by the garbage collector.
Therefore the programmer needs to call Dispose() method of IDisposable
interface.
Dispose () of IDisposable interface is called by the programmer to explicitly release resources when they are no longer being used. Dispose () can be called even if other references to the object are alive. Define Collections in .NET and briefly explain its types?
Q-Define
Collections in .NET and briefly explain its types?
From
a .NET perspective, a collection could be defined as an object that implements
one or more of the System.Collections.ICollection,
System.Collections.IDictionary, and System.Collections.IList interfaces. This
definition leads to my classification of the "built-in" collections
found in the System.Collections namespace into three broad categories:
•Ordered collections: Collections that implement only the ICollection interface are usually distinguished by the fact that insertion order controls the order in which objects may be retrieved from the collection. The System.Collections.Stack and System.Collections.Queue classes are both examples of ICollection collections.
•Indexed collections: IList-implementing collections are distinguished by the fact that their contents can be retrieved via a zero-based numeric index, like an array. The System.Collections.ArrayList object is one example of an indexed collection.
•Keyed collections: Collections implementing the IDictionary interface contain items that can be retrieved by an associated key value of some kind. The contents of IDictionary collections are also usually sorted in some fashion based on the key value and can be retrieved in sorted order by enumeration. The System.Collections.HashTable class implements the IDictionary interface
•Ordered collections: Collections that implement only the ICollection interface are usually distinguished by the fact that insertion order controls the order in which objects may be retrieved from the collection. The System.Collections.Stack and System.Collections.Queue classes are both examples of ICollection collections.
•Indexed collections: IList-implementing collections are distinguished by the fact that their contents can be retrieved via a zero-based numeric index, like an array. The System.Collections.ArrayList object is one example of an indexed collection.
•Keyed collections: Collections implementing the IDictionary interface contain items that can be retrieved by an associated key value of some kind. The contents of IDictionary collections are also usually sorted in some fashion based on the key value and can be retrieved in sorted order by enumeration. The System.Collections.HashTable class implements the IDictionary interface
Q-What are
Generics in C#.Net?
The
generics feature in C# has been introduced with version 2.0 of the .NET
Framework and these are just like templates in C++. Using generics we can
create classes, methods, events, delegates which work with any type (like int,
string, myclass etc). The Advantages with Generics are Performance will
increase, Code Reusability and Type Safety.
For
every data type the generic class is generated, a separate instance of the
class is loaded by the class loader in CLR.
Q-
What is the difference between String and StringBuilder?
Both
String and StringBuilder are classes used to handle strings.
The most common operation with a string is concatenation. This activity has to be performed very efficiently. When we use the "String" object to concatenate two strings, the first string is combined to the other string by creating a new copy in the memory as a string object, and then the old string is deleted. This process is a little long. Hence we say "Strings are immutable".
When we make use of the "StringBuilder" object, the Append method is used. This means, an insertion is done on the existing string. Operation on StringBuilder object is faster than String operations, as the copy is done to the same location. Usage of StringBuilder is more efficient in case large amounts of string manipulations have to be performed.
The most common operation with a string is concatenation. This activity has to be performed very efficiently. When we use the "String" object to concatenate two strings, the first string is combined to the other string by creating a new copy in the memory as a string object, and then the old string is deleted. This process is a little long. Hence we say "Strings are immutable".
When we make use of the "StringBuilder" object, the Append method is used. This means, an insertion is done on the existing string. Operation on StringBuilder object is faster than String operations, as the copy is done to the same location. Usage of StringBuilder is more efficient in case large amounts of string manipulations have to be performed.
Q-What
is the difference between a DataReader and Dataset in ADO.NET?
A
DataReader works in a connected environment, whereas DataSet works in a
disconnected environment.
A DataReader object represents a forward only, read only access to data from a source. It implements IDataReader & IDataRecord interfaces. For example, The SQLDataReader class can read rows from tables in a SQL Server data source. It is returned by the ExecuteReader method of the SQLCommand class, typically as a result of a SQL Select statement.
A DataReader object represents a forward only, read only access to data from a source. It implements IDataReader & IDataRecord interfaces. For example, The SQLDataReader class can read rows from tables in a SQL Server data source. It is returned by the ExecuteReader method of the SQLCommand class, typically as a result of a SQL Select statement.
A
DataSet represents an in-memory cache of data consisting of any number
of inter-related DataTable objects. A DataTable object represents a tabular
block of in-memory data. Further, a DataRow represents a single row of a
DataTable object. A Dataset is like a mini-database engine, but its data is
stored in the memory. To query the data in a DataSet, we can use a DataView
object.
Q- What is versioning
in .NET?
main
advantage of .net is versoning and solve very critical problem.
.net
maintain one application with more then one version and also solve DLL HELL
problem because it can run same application with diffrent version at a same
time.
Q-
Difference between User Controls and Custom server control
User
control
1.Compiled
at runtime
2.HTML
design (Visual design possible)
3.ASP.Net
page model with code behind
4.Needs
ASP.NET .aspx page to exist (can be used)
5.No
design time interface
(Only
a box representing the user control is available on an .aspx page)
6.Cannot
be added to the ToolBox
Custom
Server Control
1.Precompiled
2.No
visual design. HTML needs to be declared programmatically
3.Component
model
4.can
be used in .aspx pages, user controls or other custom server controls.
5.Has
design-time and run-time interface
6.
Can be added to the ToolBox (using drag and drop)
View
State is
one of the most important and useful client side state management mechanism. It
can store the page value at the time of post back (Sending and Receiving
information from Server) of
your page. ASP.NET pages provide the ViewState property as a built-in structure
for automatically storing values between multiple requests for the same page.
- Easy to implement
- No server resources are required
- Enhanced security features ,like it can be encoded and compressed.
- It can be performance overhead if we are going to store larger amount of data , because it is associated with page only.
- Its stored in a hidden filed in hashed format (which I have discussed later) still it can be easily trapped.
- It does not have any support on mobile devices.
View
State stored the value of page controls as a string which is hashed and encoded
in some hashing and encoding technology. It only contain information about page
and its controls. Its does not have any interaction with server. It
stays along with the page in the Client Browser. View State use Hidden field to store its
information in a encoding format.
Delegates
A
delegate in C# is similar to a function pointer in C or C++. Using a delegate
allows the programmer to encapsulate a reference to a method inside a delegate
object. The delegate object can then be passed to code which can call the
referenced method, without having to know at compile time which method will be
invoked.
Multicast
Delegates
In
C#, delegates are multicast, which means that they can point
to more than one function at a time (that is, they're based off the
System.MulticastDelegate type). A multicast delegate maintains a list of
functions that will all be called when the delegate is invoked.
Q-
What is global.asax in ASP.NET? Application_start, Session_start?
The
global.asax file is used to add application level logic & processing. Note
that the global.asax does not handle any UI related processing, nor does it
process individual page level requests. It basically controls the following
events...
Application_Start
Application_End
Session_Start
Session_End
Application_Start
Application_End
Session_Start
Session_End
Code
in the global.asax is compiled when the web appication is built for the first
time. The application level code and variables may be declared in
Application_Start. Similarly, session level code & variables may be
declared in Session_Start event. Application level events are for the entire
application, and may be used for any user, while Session level events are user
specific for a length of a session.
Caching
Caching
is the process of storing frequently used data, usually data that is costly to
generate, for reuse. Typically this data is stored in memory since retrieving
data from memory is much more efficient than retrieving the data from other
locations, such as a database.
No comments:
Post a Comment