Thursday, 12 December 2013

.Net fundamental

1)Which ADO.NET object is very fast in getting data from database?

   DataReader is the  object which retrieve data from database verifiable.
   for example SqlDataReader , OledbDataReader

   DataReader is the object which was introduced in .net from earlier version. Even Dataset use
   DataReader  object internally for data retrieving.DataReader use connected data retrieval only
  
2)Explain about the relationship of XML and ADO.NET?

ADO.Net was intoduced in .net framework.ADO.Net dataset is a class for handling  data operation.Data fetch, update etc. ADO.Net dataset is of two type a)Typed and b)Untyped dataset.Both are derived from dataset class.

a)Typed dataset : It is derived from ADO.Net dataset and all method , event,property also from ADO.Net class.When a typed dataset is generated at design time, a dataset class and an associated XML Schema is created.XML Schemas define and validate the data being imported from XML streams or documents into typed datasets.

b)Untyped dataset : It is derived from ADO.Net also.

3)Explain about Data access objects or DAO?

4)How to add auto increment column in the DataTable?

It is a tricky question , asked by employer , to know in depth knowledge of a candidate.
Datatable also an inmemeory representation.Data table had a property called "AutoIncrement" 
thta is DataColumn.AutoIncrement 

DataTable table = new DataTable("mytable");
 
DataColumn mycolumn = new DataColumn();
column.DataType = System.Type.GetType("System.Int32");
column.AutoIncrement = true;
table.Columns.Add(mycolumn);
 
5)Stored procedure return more than one resut set and datareader used to fetch record, how you fetch 6)second result set using datareader?
7)What is the use of DataSet.HasChanges() Method?

Gets indicating whether the  dataset  has changes, including new, deleted, or modified rows.
   if(mydataSet.HasChanges()) return;

Sometimes programetically  we cange the value of a datatable , add new row, delete row, modify    value of column.Or some times add a new datatable added to dataset.

To determine if the value has change , HasChanges() property is used
  

8)What is the use of SqlCommandBuilder?
A Command object is used to execute scalar or non query commands to a Databse.

It comes under System.Data.Sqlclient.It is a sealed class.

SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = new SqlCommand(myQueryString, connection);
SqlCommandBuilder builder = new SqlCommandBuilder(da );
builder.GetUpdateCommand(); 
 

9)What is the difference between Typed and UnTyped DataSets?
Dataset is derived from System.Data.DataSet.There are two type of dataset , Typed and untyped dataset.Both are dataset but have some major advantages of Typed dataset over untyped dataset.Mainly when we declare a dataset ,it is untyped dataset , but .Xsd file is a good example of typed dataset

untyped dataset
dataset ds=new dataset();

typed dataset is and .xsd file
now  what more on typed dataset ?
Typed dataset maintain schema .Foreign key and others reference,Relation between tables.
we can not violate the database integrity programetically form typed dataset
 

10)Differences between DataSet and DataReader

DataSet

DataReader

Can perform both Read/Write
Can perform only Read-only operation
Can return /contain multiple tables from different databases
Can read on a single result set of one database
Disconnected mode
Connected mode
Can bind to multiple controls
Can bind to a single control
Forward and backward scanning of data, any point of data can be access
Forward-only scanning of data
Slower access to data
Faster access to data
Greater overhead to enable additional features
Lightweight object with very little overhead
 Internally XML is used for storing of data.
No scope of storing of data.




11)How do you create a permanent cookie ?

It is also termed as persistent cookie or a stored cookie

cookie that is stored on a users hard drive until it expires or until the user deletes the cookie. This cookies are used to collect identifying information about the user, such as Web surfing behavior or user preferences for a specific Web site.Expire date are set to get expired

Add cookie
var myCookie = new HttpCookie("myCookie ");
myCookie .Values.Add("Id", "some_information");
panelIdCookie.Expires = DateTime.Now.AddMonths(2); 
Response.Cookies.Add(myCookie );
 
Read cookie
 var httpCookie = Request.Cookies["myCookie "];
 if (httpCookie != null)
 {
   myId = Convert.ToInt32(httpCookie["Id"]);
 }
 


12)What is gacutil.exe?

 gacutil stands for Global Assembly Cache (GAC),it is for the Common Language Infrastructure (CLI).It is automatically installed when a visual studio is installed,to run the tool we have to go to
"Command Prompt".gacutil accept three parameters

assemblyName,assemblyPath,assemblyListFile

we can see the gacutil.exe like the path
 %programfiles%\Microsoft Visual Studio .NET 2005\SDK\v1.1\Bin\gacutil.exe


13)Difference between Response.Expires and Response.ExpiresAbsolute?

Response.Expires
Specifies the number of minutes before a page cached in the browser expires . if the user returns to the same page before the specified number of minutes the cached version of the page is displayed.
Response.Expires = 40
Response.Cache.SetNoStore()
by this  cached in the browser expires in 40 minutes

Response.ExpiresAbsolute
This can set the date and/or time at which page cached in the browser expires.
 <% Response.ExpiresAbsolute=#May 31,2013 13:30:15# %>

14)What is CLR (Common Language Runtime)?

                                     It is a  run-time environment called the common language runtime, which runs the code and provides services that make the development process easier.
                                   The term service refers to as a collection of services that are required to execute a code. The beauty of CLR is that all .NET-supported languages can be executed under this single defined runtime layer. The spinal cord of CLR is represented by a library refers to as mscoree.dll (common object runtime execution engine). When an assembly is referenced for use, mscoree.dll is automatically loaded.
                                 The CLR first locates the referenced assembly, and then it loads it into memory, compiles the associated IL code into platform specific instructions, performs security related checks, and finally executes the code.
 
Role of CLR in DOT.NET Framework
Base Class Libraries: It provides class libraries supports to an application when needed.
Debug Engine: CLR allows us to perform debugging an application during runtime. Thread Support: Threads are managed under the Common Language Runtime
Manages memory: Allocation of Memory,De-Allocation of Memory (garbage collation)
Compilation

                                Common Language Runtime (CLR) is a language-independent runtime environment . The Common Language Runtime (CLR) environment is also referred to as a managed environment, because during the execution of a program it also controls the interaction with the Operating System


15)What is CTS?

                               CTS stands for Common Type System. It confirm how Type definitions and specific values of Types are represented in computer memory.Which establishes a framework that helps enable cross-language integration, type safety, and high-performance code execution.Provides an object-oriented model that supports the complete implementation of many programming languages
                            
                              The language interoperability, and .NET Class Framework, are not possible without all the language sharing the same data types.This is exactly what's done in the Common Type System (CTS). A fundamental part of the .NET Framework's Common Language Runtime (CLR), the CTS specifies no particular syntax or keywords, but instead defines a common set of types that can be used with many different language syntaxes. Each language is free to define any syntax it wishes, but if that language is built on the CLR, it will use at least some of the types defined by the CTS.
                            These types can be Value Types or Reference Types . The Value Types are passed by values and stored in the stack. The Reference Types are passed by references and stored in the heap. Common Type System (CTS) provides base set of Data Types which is responsible for cross language integration. The Common Language Runtime (CLR) can load and execute the source code written in any .Net language, only if the type is described in the Common Type System (CTS) .Most of the members defined by types in the 
                            
      


16)What is CLS?
17)What is MSIL?

Full form of  MSIL is Microsoft Intermediate Language.Also called  Intermediate Language (IL) / Common Intermediate Language (CIL). While compile , the compiler convert the source code into Microsoft Intermediate Language (MSIL).MSIL includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations.
Combined with metadata and the common type system, MSIL allows for true cross- language integration Prior to execution, MSIL is converted to machine code. It is not interpreted.

18)What is Satellite Assembly?
19)Can you place two .dll files with the same name in GAC (Global Assembly Cache)?
20)What's the difference between private and shared assembly?

Private Assembly
                                A private assembly is normally used by a single application, and is stored in the application's directory, or a sub-directory beneath.
                               The disadvantage of using private assemblies is that they have to be copied into every application that uses it. This results in increased disk space requirements on the target machine - the same private assembly is copied to disk multiple times - and in memory requirements - the same DLL loaded from different locations is seen by Windows as a different module and is allocated separate physical memory.

Shared Assembly
                         A shared assembly is an assembly available for use by multiple applications on the computer.This type of assembly can be used in situations where it is not necessary to install a version of an assembly for each application that uses it


21)What is the location of Global Assembly Cache on the system.

22)What is JIT (Just-in-time) Compiler ?
A compiler that converts program source code into native machine code just before the program is run. Compilation is a executes in two-steps.It required an  Virtual Machine which is able to execute
execute your code.
Step 1
Convert  your program to a bytecode understandable by Virtual Machine. .NET  is called Common Intermediate Language or CIL. It is also known as Microsoft Intermediate Language (MSIL) or just Intermediate Language (IL)

Step 2
Virtual Machine  converts only executed MSIL  into CPU instructions at runtime.

23)What is Managed and Unmanaged code?
24)What is the difference between Namespace and Assembly?
25)What is Manifest?
26)What is Metadata?
27)What is CODE Access security?
28)What’s difference between System.SystemException and System.ApplicationException?
30)Dictionary objects 

Contain collection of keys and values.comes under System.Collections.Generic
Dictionary<TKey, TValue>()

Example
public class AClass
{
Dictionary<int, dynamic> sp = new Dictionary<int, dynamic>
{
{1, new {name="Ram", age="18"}}
{2, new {name="Sham", age="22"}}
}
}

Now how to read dictionary object?
 
AClass obj = new AClass(); 
 
foreach (var item in obj.sp)
{
    Console.Write(item.Key);
    Console.Write(item.Value.name);
    Console.Write(item.Value.age);
} 


31)What is ResolveUrl ?

Converts a URL into one that is usable on the requesting client .
For example i have a path
../event/play/sport.aspx
Now some other path , i have to redirect to the sport.aspx page
Say i am in a path
../event/study/class.aspx
i have to rend the redirect to
../event/play/sport.aspx

if i write  string postTo=ResolveUrl(`~/sport.aspx);
Response.write( postTo.totsring());
Result
../event/study/class.aspx 

No comments:

Post a Comment

বাঙালির বেড়ানো সেরা চারটি ঠিকানা

  বাঙালি মানে ঘোড়া পাগল | দু একদিন ছুটি পেলো মানে বাঙালি চলল ঘুরতে | সে সমুদ্রই হোক , পাহাড়ি হোক বা নদী হোক। বাঙালির ...