tag:blogger.com,1999:blog-33297360173150215352024-03-27T16:53:04.250-07:00C# Interview Questions TopicWiseUnknownnoreply@blogger.comBlogger30125tag:blogger.com,1999:blog-3329736017315021535.post-58934191071909300632012-08-28T20:03:00.000-07:002010-12-22T19:58:57.218-08:00HomeHi All.<br />
<br />
I am still under the process of covering all the topics. Keep coming back as there will be lots of new ques added everyday which will help you guys in your job interviews.<br />
<br />
I have also added real time scenarios that i have experienced while implementing each concepts. So every topic contains the interview ques and also real time problems that can occur.<br />
<br />
Also you guys can send me any ques that can be added to the list.Hope it helps everyone to prepare for interview and also get to know about the language. <br />
<br />
Good Luck !!!Unknownnoreply@blogger.com142tag:blogger.com,1999:blog-3329736017315021535.post-5425349366327859912011-02-07T00:08:00.001-08:002011-05-29T19:58:05.046-07:00MISC<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Verdana,sans-serif;"><b><span style="font-size: small;">Retrieve the image content from database</span></b></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;">When the data from image field is extracted from database it is in form of byte array.Below is the code to convert an object to a byte array-</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;">byte[] data= (byte[])ds.Tables[0].Rows[0][0];</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Verdana,sans-serif;"><b><span style="font-size: small;">Check if user has clicked a check box in a datagrid</span></b></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;">foreach (DataGridViewRow row in dataGridView1.Rows)</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;">{</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;">if (row.Cells[0].Value != null &&</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;">Convert.ToBoolean(row.Cells[0].Value) == true)</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;">{</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;">//the user has clicked the check box..retrieve the values accordingly</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;">} }</span><br />
<br />
<span style="font-size: small;"><br />
<b>Restore databse from a .bak file</b><br />
Execute the following command .Specify the path where .bak file is located.<br />
<br />
RESTORE DATABASE Test<br />
<br />
FROM DISK = <File Location><br />
<br />
WITH REPLACE, MOVE '<MDFFileName>' TO 'c:\Program Files\Microsoft SQL Server\CADS.MDF',<br />
<br />
MOVE '<LDFFileName>' TO 'c:\Program Files\Microsoft SQL Server\\CADS_Log.LDF'<br />
<br />
<br />
The <MDFFileName> and <LDFFileName> file names can be obtained by executing the follwoing query<br />
<br />
<br />
RESTORE FILELISTONLY<br />
<br />
FROM DISK = <File Location><br />
<br />
GO<br />
<br />
Sometimes you will see an error stating no access.some other process is using the database..Execute the below command that time<br />
<br />
Alter Database System<br />
<br />
SET SINGLE_USER With ROLLBACK IMMEDIATE </span><br />
<br />
<b><span style="font-size: small;"> Restore database using .ldf amd .mdf files</span></b><br />
<br />
sp_attach_db 'Database_Name','c:\backupDB.mdf','C:\backupLogs.ldf'<span style="font-size: small;"> </span></div></div>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-3329736017315021535.post-57595494339976992022011-01-11T17:41:00.000-08:002011-03-07T20:12:59.882-08:00Windows Service<div dir="ltr" style="text-align: left;" trbidi="on"><b><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">How to find out if a service present in different machine has been stopped or started</span></span></b><br />
<span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span><br style="font-family: Verdana,sans-serif;" /><span style="font-family: Verdana,sans-serif;">Use ServiceController Class present in System.ServiceProcess namespace to determine the status of the service. Have a timer in the application which is monitoring the service. The timer should poll service to determine its status.</span></span><br />
<span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span><br style="font-family: Verdana,sans-serif;" /><span style="font-family: Verdana,sans-serif;">ServiceController c = new ServiceController("<servicename>", "<machine name>");</span></span><br />
<div style="font-family: Verdana,sans-serif;"><br />
</div><b><span style="font-family: Verdana,sans-serif;">Does windows service pick up any changes made to app.config when its running ?</span></b><br />
<br />
<span style="font-family: Verdana,sans-serif;"> No. The service needs to be restarted to pick up any new changes made to the config file.</span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><br />
<br />
<span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b>Debug a windows service </b></span></span><br />
<br />
<span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b> </b>Below are the three methods</span></span><br />
<span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><br />
</span></span><br />
<span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">1.Create a new test class. Then call the functions from test class.</span></span><br />
<br />
<span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">2.Add a line </span></span><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b> System.Diagnostics.Debugger.Break(); </b>wherever you want to debug.At runtime a new instance will be created and debugging can be carried out in separate windows.</span></span><br />
<span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b><br />
</b></span></span><br />
<span style="font-size: small;"><span style="font-family: Verdana,sans-serif;">3.Please refer </span></span><br />
<span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span><a href="http://aspalliance.com/1316_Working_with_Windows_Service_Using_Visual_Studio_2005.6">http://aspalliance.com/1316_Working_with_Windows_Service_Using_Visual_Studio_2005.6</a><br />
<br />
<br />
<b><span style="font-family: "Verdana","sans-serif";">How to install a windows service</span></b><br />
<br />
<span style="font-family: "Verdana","sans-serif";">Go to visual studio command prompt. Navigate to path where the exe that you want to install is present.</span><br />
<br />
<span style="font-family: "Verdana","sans-serif";">To install, type</span><br />
<span style="font-family: "Verdana","sans-serif";">installutil projectname.exe</span><br />
<br />
<span style="font-family: "Verdana","sans-serif";">To uninstall, type</span><br />
<span style="font-family: "Verdana","sans-serif";">installutil /u projectname.exe</span><br />
<br />
<span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> </span></span> <m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent> </m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac><br />
<div class="MsoNormal" style="margin-left: 18pt;"><a href="http://aspalliance.com/1316_Working_with_Windows_Service_Using_Visual_Studio_2005.6"><br />
</a><br />
<br />
<br />
<br />
<br />
</div><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"><b> </b></span></span></div>Unknownnoreply@blogger.com6tag:blogger.com,1999:blog-3329736017315021535.post-54263987905144059922010-11-25T17:25:00.000-08:002011-03-08T01:33:54.148-08:00WebService<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: Verdana,sans-serif;"><u><b>Calling Webservice Asyncronously in windows application</b></u></div><div style="font-family: Verdana,sans-serif;"><br />
</div><div style="font-family: Verdana,sans-serif;"><m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent> </m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac></div><div style="font-family: Verdana,sans-serif;">Calling webservice async in Windows Application</div><div style="font-family: Verdana,sans-serif;">1.Create a web service.</div><div style="font-family: Verdana,sans-serif;">2.Add web reference to your windows app. In order to do this Click add service reference -> advanced setting>add web reference.</div><div style="font-family: Verdana,sans-serif;">This is needed bc Async <span style="font-size: small;">methods will not be generated if you add a normal web reference.</span></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;">The remaining can be done by below article</span></div><div style="font-family: Verdana,sans-serif;"><br />
</div><div style="font-family: Verdana,sans-serif;"><a href="http://weblogs.asp.net/stevewellens/archive/2010/04/02/calling-web-service-functions-asynchronously-from-a-web-page.aspx">http://weblogs.asp.net/stevewellens/archive/2010/04/02/calling-web-service-functions-asynchronously-from-a-web-page.aspx</a></div><div style="font-family: Verdana,sans-serif;"><br />
</div><div style="font-family: Verdana,sans-serif;"><m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent> </m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;"><b><u>Web Service Completed Events Firing Twice</u></b></span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;"><b><u><br />
</u></b></span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">For this initialize your webservice object to null in beginning. And later when you use its method instantiate it.</span><span style="font-size: small;"><b><u> </u></b></span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">eg-</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">Webservice </span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">public class Service1 : System.Web.Services.WebService</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">{ </span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">[WebMethod] </span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">public string SendData()</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">{</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;"> return "Data Sent";</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">}</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">} </span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><br />
</div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">WebMethod referred in windows app</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><br />
</div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">public class TestClass</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">{</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><br />
</div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;"><ServiceNameGiven>. Service1 objService=null; //intialize it to null intially</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;"> public void TestMethod()</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">{</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">//now instantiate it. </span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;"> </span><span style="font-size: small;"><ServiceNameGiven>. Service1 objService=new </span><span style="font-size: small;"><ServiceNameGiven>. Service1();</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">} </span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;"><span style="font-family: Arial,Helvetica,sans-serif;">} </span></span><br />
<br />
<div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><u><b>Timeout issue in webservice </b></u></span></div><br />
Error message-<br />
<span style="font-size: x-small;"><br style="font-family: Verdana,sans-serif;" /></span><br />
<div style="font-family: Verdana,sans-serif;"><m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent> </m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; margin-left: 18pt;"><m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent> </m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; margin-left: 18pt;"><span style="font-size: small;"><i>The request channel timed out while waiting for a reply after 00:00:02.1500000.</i> <i>Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout</i></span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; margin-left: 18pt;"><br />
</div><div class="MsoNormal" style="font-family: Verdana,sans-serif; margin-left: 18pt;"><span style="font-size: small;"><i></i></span></div><m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent><span style="font-size: small;"><i><span style="font-family: "Calibri","sans-serif";"></span></i><i><span style="font-family: "Calibri","sans-serif"; font-style: normal;"></span></i></span> </m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;">This issue is caused because of some operation that takes longer time than that configured in your webservice and your client setting . to fix this –make the following setting <br />
<br />
1.In your webservice add the following settings-<br />
<br />
The setting is in web.config file<br />
</span><span style="font-size: small;"><configuration></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"> <system.web></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"> <httpRuntime maxRequestLength="8096"</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"> useFullyQualifiedRedirectUrl="true"</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"> executionTimeout="1800"/> //set for 30 min</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"> </system.web></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"></configuration></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><br />
</div><m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent> <m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent>2.On your client side(the application that is consuming the webservice)<br />
Change the sendTimeout = "00:30:00" //desired time you want.<br />
This wil be in app.config file</m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac></m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;"><u><b>Returning value from a asyn webservice</b></u></span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><br />
Below is the webservice example-</div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">Webservice </span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">public class Service1 : System.Web.Services.WebService</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">{ </span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">[WebMethod] </span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">public string SendData()</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">{</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;"> return "Data Sent";</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">}</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal;"><span style="font-size: small;">}</span><br />
<span style="font-size: small;"> </span><br />
<span style="font-size: small;">Calling app--windows app</span><br />
<span style="font-size: small;">1.Add webreference to the given service.</span><br />
<span style="font-size: small;">2. intialialize the webservice object in the onload</span><br />
<br />
<span style="font-size: small;"><AddedwebServiceName>.Service1 obj= new </span><span style="font-size: small;"><AddedwebServiceName>.Service1()</span><br />
<br />
<span style="font-size: small;">Create a event handler for the completed function exposed by webmethod</span><br />
<span style="font-size: small;"><AddedwebServiceName>.SendDataCompleted += EventHandler</span><br />
<span style="font-size: small;"> </span><br />
<span style="font-size: small;">3.Call the asyn function in any event like button click</span><br />
<span style="font-size: small;"><AddedwebServiceName>.SendDataAsync</span><br />
<br />
<span style="font-size: small;">4.Add the functions which will be invoked when a function is completed</span><br />
<span style="font-size: small;"> </span><br />
<span style="font-size: small;"> public void EventHandler(object sender, localhost.</span><span style="font-size: small;">SendDataCompleted</span><span style="font-size: small;">EventArgs e)</span><br />
<span style="font-size: small;">{</span><br />
<span style="font-size: small;"> //this will give you the result.since webmethod returns a string this functions will give string value.</span><br />
<span style="font-size: small;">string result =e.result</span><span style="font-size: small;"></span><br />
<br />
<span style="font-size: small;">}</span><br />
<br />
<span style="font-size: small;"><u><b>Steps to take care when changing the default class name of webservice </b></u></span><br />
<span style="font-size: small;"><br />
</span></div><span style="font-size: small;">1. suppose your newly added webservice generated the below class for you</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"> public class Service1 : System.Web.Services.WebService</span><br />
<span style="font-size: small;">{</span><br />
<span style="font-size: small;">}</span><br />
<span style="font-size: small;"><b><u><br />
</u></b></span><br />
<span style="font-size: small;">change the class name to desired class name eg-</span><br />
<br />
<span style="font-size: small;"> public class MyWebservice: System.Web.Services.WebService</span><br />
<span style="font-size: small;">{</span><br />
<span style="font-size: small;">}</span><br />
<br />
<span style="font-size: small;">2. Search for "Codebehind in your solution. it openes up </span><span style="font-size: small;">Service1.asmx with below line</span><br />
"<%@ WebService Language="C#" CodeBehind="service1.asmx.cs" Class="<namespace>.service1" %>"<br />
<br />
Change the Class in the above tag to <Namespace>.Mywebservice(or as desired)<br />
<br />
<span style="font-size: small;"><br />
</span><br />
<br />
<span style="font-size: small;"><u><b>The test form is only available for requests from the local machine </b></u></span><br />
<br />
<span style="font-size: small;">If you want to test your simple webservice by clicking on "Invoke" button it should be enabled for remote access.<br />
The invoke button wont be available if your webservice is accessed remotely however it will be available locally.<br />
To enable this setting add foll to your config file-<br />
<br />
<configuration><br />
<system.web><br />
<webServices><br />
<protocols><br />
<add name="HttpGet"/><br />
<add name="HttpPost"/><br />
</protocols><br />
</webServices><br />
</system.web><br />
</configuration></span><br />
<br />
<br />
<b><u><span style="font-family: "Verdana","sans-serif";">Method overloading in webservice</span></u></b><br />
<br />
<span style="font-family: "Verdana","sans-serif";">Remember webservice cannot have two webservice with same name and same parameters(this cannot be don’t anyhow).</span><br />
<br />
<span style="font-family: "Verdana","sans-serif";"> However method overloading is possible.The methods that are being overloaded should have an external name given by “MessageName”</span><br />
<br />
<span style="font-family: "Verdana","sans-serif";">[WebMethod( MessageName = "AddInt")]</span><br />
<span style="font-family: "Verdana","sans-serif";">Public void Add(int a,int b)()</span><br />
<span style="font-family: "Verdana","sans-serif";">{</span><br />
<span style="font-family: "Verdana","sans-serif";">}</span><br />
<br />
<span style="font-family: "Verdana","sans-serif";">[WebMethod( MessageName = "AddFloat")]</span><br />
<span style="font-family: "Verdana","sans-serif";">Public void Add(float a,float b)()</span><br />
<span style="font-family: "Verdana","sans-serif";">{</span><br />
<span style="font-family: "Verdana","sans-serif";">}</span><br />
<br />
<span style="font-family: "Verdana","sans-serif";">This solution will work in older version of dot net. But in .Net 2.0 it will give an error saying the webservice does not confirm to (WS-I) Baisc Profile 1.1..</span><br />
<br />
<span style="font-family: "Verdana","sans-serif";">To solve this set </span><br />
<br />
<span style="font-family: "Verdana","sans-serif";">[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]</span><br />
<br />
<span style="font-family: "Verdana","sans-serif";">At the beginning of the code to</span><br />
<br />
<span style="font-family: "Verdana","sans-serif";">[WebServiceBinding(ConformsTo = WsiProfiles.None)] </span><br />
<br />
<br />
<b><u><span style="font-family: "Verdana","sans-serif";">How do you call a same webservice when its hosted in multiple server dynamically at runtime</span></u></b><br />
<br />
<span style="font-family: "Verdana","sans-serif";">When a webservice is added to the client WSDL is generated. This WSDL will have a URL of the webservice. So the added webreference is associated with a single URL.</span><br />
<br />
<span style="font-family: "Verdana","sans-serif";">Now if the same webservice present in some other server needs to be called then this URL needs to be changed. This can be done dynamically at run time.</span><br />
<span style="font-family: "Verdana","sans-serif";">Before calling the webservice change the URL to the URL where the calling webservice will be located.</span><br />
<span style="font-family: "Verdana","sans-serif";">eg- </span><br />
<span style="font-family: "Verdana","sans-serif";">string path = "http://" + IpAddress + WebServiceURlPath;</span><br />
<span style="font-family: "Verdana","sans-serif";"> <WebserviceObject>.Url = path;</span><br />
<br />
<br />
<b><u><span style="font-family: "Verdana","sans-serif";">Windows Authentication in WebService</span></u></b><br />
<span style="font-family: "Verdana","sans-serif";">In order to achieve this perform the following steps</span><br />
<br />
<span style="font-family: "Verdana","sans-serif";">1.Change the authentication mode to “Windows” in web.config file in the webservice.</span><br />
<br />
<span style="font-family: "Verdana","sans-serif";"><authentication mode="Windows" /></span><span style="font-family: "Verdana","sans-serif";"> </span><br />
<br />
<span style="font-family: "Verdana","sans-serif";">2.Just before calling any webservice methods on the client side set the “Credentials” property of webservice.</span><br />
<br />
<span style="font-family: "Verdana","sans-serif";">Eg-</span><br />
<span style="font-family: "Verdana","sans-serif";"><webserviceName>.Credentials = new System.Net.NetworkCredential(UserName, Password);</span><br />
<br />
<div style="margin-bottom: 12pt;"><span style="font-family: "Verdana","sans-serif";">3.Make changes in IIS to enable Windows Authentication.</span></div><div style="margin-bottom: 12pt;"><span style="font-family: "Verdana","sans-serif";">Navigate to the website where your service is hosted in IIS Manage and disable “Anonymous Authentication “ and enable “Windows Authentication”.</span></div><br />
<br />
<div style="margin-bottom: 12pt;"><b><span style="font-family: "Verdana","sans-serif";">1.What is WebService?</span></b></div><div style="margin-bottom: 12pt;"><span style="font-family: "Verdana","sans-serif";">Webservice are functionalities or web APIs exposed over the web.</span></div><div style="margin-bottom: 12pt;"><span style="font-family: "Verdana","sans-serif";">It can be developed in any language. It is platform independent </span></div><div style="margin-bottom: 12pt;"><span style="font-family: "Verdana","sans-serif";">Webservice communication takes place via SOAP(Simple Object Access Protocol).So any language capable of communicating via SOAP can consume webservice.</span></div><div style="margin-bottom: 12pt;"><span style="font-family: "Verdana","sans-serif";">Webservice are used in SOA architecture. </span></div><div style="margin-bottom: 12pt;"><br />
</div><div class="MsoNormal"><b><span style="font-family: "Verdana","sans-serif"; font-size: 12pt; line-height: 115%;">2. What are different components in Webservice ?</span></b></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: "Verdana","sans-serif";">ASMX file- This file provides access to the webservice.</span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: "Verdana","sans-serif";">DISCO(Discovery of Webservice) files- This are used to locate the webservice. They contain the path where the webservice is located.</span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: "Verdana","sans-serif";">WSDL(Webservice Description Language)- these are used to describe the webservice. They give details about the methods exposed by the webservice and the parameters they take.</span></div><div class="MsoNormal"><span style="font-family: "Verdana","sans-serif";">They can be accessed by appending “?WSDL” to the webservice path.</span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: "Verdana","sans-serif";">UDDI(Universal Description, Discovery and Integration) -It is a repository where different webservice can be located.</span><br />
<br />
<br />
<div class="MsoNormal"><span style="font-family: "Verdana","sans-serif";">SOAP(Simple Object Access Protocol) –Its a XML based protocol which is used be send request and get response back from the webservice.</span></div><br />
<br />
<div class="MsoNormal"><b><u><span style="font-family: "Verdana","sans-serif"; font-size: 12pt; line-height: 115%;">4.How do you deploy a webservice ?</span></u></b></div><div class="MsoNormal"><span style="font-family: "Verdana","sans-serif";">Webservice are deployed in IIS either manually or through a set up project.</span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: "Verdana","sans-serif";">Manual deployment</span></div><div class="MsoNormal"><span style="font-family: "Verdana","sans-serif";">1.Create a new virtual directory in IIS. Point the path of the virtual directory to a <Sample >folder sotred in the hard disk.</span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: "Verdana","sans-serif";">2.The <Sample>folder will contain bin folder,asmx file and web.config of the webserive.</span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="font-family: "Verdana","sans-serif";">3.The service can now be accessed by typing following in the browser</span></div><div class="MsoNormal"><span style="font-family: "Verdana","sans-serif";">http://<ip of the machine where service is hosted>/<virtual directory name>/<asmx file name>.asmx</span></div></div><span style="font-size: small;"> </span><span style="font-size: small;"><u><b> </b></u></span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; margin-left: 18pt;"><br />
</div><div class="MsoNormal" style="font-family: Verdana,sans-serif; margin-left: 18pt;"><span style="font-size: small;"><br />
<br />
</span> </div></div>Unknownnoreply@blogger.com5tag:blogger.com,1999:blog-3329736017315021535.post-4152340990218245302010-11-15T16:51:00.001-08:002011-02-16T00:39:23.080-08:00XML<m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent> </m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac><br />
<b><span style="font-family: Verdana,sans-serif;">What is XML Serialization ?</span></b><br />
<br />
<span style="font-family: Verdana,sans-serif;">Xml serialization allows reading and write in the xml using dot net objects.</span>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-3329736017315021535.post-34989561579570818652010-11-02T00:10:00.001-07:002010-11-02T00:10:13.109-07:00Adding configuration file in a 3 tier architecture<div class="MsoNormal" style="margin: 0cm 0cm 10pt;"><span style="font-family: Calibri;">1.Add a single app.config file in the UI Layer</span></div><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;"><?</span><span style="color: #a31515; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">xml</span><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;"> </span><span style="color: red; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">version</span><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">=</span><span style="font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">"<span style="color: blue;">1.0</span>"<span style="color: blue;"> </span><span style="color: red;">encoding</span><span style="color: blue;">=</span>"<span style="color: blue;">utf-8</span>"<span style="color: blue;"> ?></span></span></div><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;"><</span><span style="color: #a31515; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">configuration</span><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">></span></div><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #a31515; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">appSettings</span><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">></span></div><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #a31515; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">add</span><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;"> </span><span style="color: red; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">key</span><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">=</span><span style="font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">"<span style="color: blue;">Server1</span>"<span style="color: blue;"> </span><span style="color: red;">value</span><span style="color: blue;">=</span>"<span style="color: blue;">10.250.1.32</span>"<span style="color: blue;"> /></span></span></div><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #a31515; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">add</span><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;"> </span><span style="color: red; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">key</span><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">=</span><span style="font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">"<span style="color: blue;"> Server 2</span>"<span style="color: blue;"> </span><span style="color: red;">value</span><span style="color: blue;">=</span>"<span style="color: blue;">10.251.1.54</span>"<span style="color: blue;"> /></span></span></div><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span></span></div><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span></</span><span style="color: #a31515; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">appSettings</span><span style="color: blue; font-family: "Courier New"; font-size: 10pt; mso-no-proof: yes;">></span></div><div class="MsoNormal" style="margin: 0cm 0cm 10pt;"><span style="color: blue; font-family: "Courier New"; font-size: 10pt; line-height: 115%; mso-no-proof: yes;"></</span><span style="color: #a31515; font-family: "Courier New"; font-size: 10pt; line-height: 115%; mso-no-proof: yes;">configuration</span><span style="color: blue; font-family: "Courier New"; font-size: 10pt; line-height: 115%; mso-no-proof: yes;">></span></div><div class="MsoNormal" style="margin: 0cm 0cm 10pt;"><br />
</div><div class="MsoListParagraph" style="margin: 0cm 0cm 10pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;"><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes;"><span style="mso-list: Ignore;">1.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%; mso-no-proof: yes;">Add the system.configuration dll refererence to the projetc where you want to access these values</span></div><div class="MsoNormal" style="margin: 0cm 0cm 10pt 18pt;"><span style="color: blue; font-family: "Courier New"; font-size: 10pt; line-height: 115%; mso-no-proof: yes;">using</span><span style="font-family: "Courier New"; font-size: 10pt; line-height: 115%; mso-no-proof: yes;"> System.Configuration;</span><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%;"> </span></div><div class="MsoNormal" style="margin: 0cm 0cm 10pt 18pt;"><span style="color: blue; font-family: "Courier New"; font-size: 10pt; line-height: 115%; mso-no-proof: yes;">//access values using below code</span><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%;"></span></div><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-SG; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-SG; mso-fareast-theme-font: minor-fareast;">String ipaddress=</span><span style="color: #2b91af; font-family: "Courier New"; font-size: 10pt; line-height: 115%; mso-ansi-language: EN-SG; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-SG; mso-fareast-theme-font: minor-fareast; mso-no-proof: yes;"> ConfigurationSettings</span><span style="font-family: "Courier New"; font-size: 10pt; line-height: 115%; mso-ansi-language: EN-SG; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-SG; mso-fareast-theme-font: minor-fareast; mso-no-proof: yes;">.AppSettings.Get(<span style="color: #a31515;">"MDT1"</span>);</span>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-3329736017315021535.post-48418758237270009112010-11-02T00:09:00.003-07:002010-11-02T00:09:56.991-07:00The requested operation requires elevation<div class="MsoNormal" style="margin: 0cm 0cm 10pt;"><span style="font-family: Calibri;">Start your<span style="mso-spacerun: yes;"> </span>VS2008/2005<span style="mso-spacerun: yes;"> </span>by clicking<span style="mso-spacerun: yes;"> </span>Run As administrator. It worked for me !!</span></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3329736017315021535.post-86073885566356068602010-11-02T00:09:00.001-07:002010-11-02T00:09:38.748-07:00Accesing multiple database using same connection in sql<div class="MsoNormal" style="margin: 0cm 0cm 10pt 18pt;"><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%; mso-no-proof: yes;">suppose you want to connect to database DB1 and DB2 in a join statement where connectionstring is same,it can be done</span></div><div class="MsoNormal" style="margin: 0cm 0cm 10pt 18pt;"><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%; mso-no-proof: yes;">as follows-</span></div><div class="MsoNormal" style="margin: 0cm 0cm 10pt 18pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 10pt 18pt;"><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%; mso-no-proof: yes;">Method1</span></b></div><div class="MsoNormal" style="margin: 0cm 0cm 10pt 18pt;"><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%; mso-no-proof: yes;">connectionstring-Data Source=P06-INF-WS-1\SQLEXPRESS;User ID=sa;Password=sa</span></div><div class="MsoNormal" style="margin: 0cm 0cm 10pt 18pt;"><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%; mso-no-proof: yes;">select * from DB1.dbo.Table1 tb1 join on DB2.dbo.Table2 tb1 where </span></div><div class="MsoNormal" style="margin: 0cm 0cm 10pt 18pt;"><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%; mso-no-proof: yes;">tb1.id=tb2.id</span></div><div class="MsoNormal" style="margin: 0cm 0cm 10pt 18pt;"><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%; mso-no-proof: yes;">Method2</span></b></div><div class="MsoNormal" style="margin: 0cm 0cm 10pt 18pt;"><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%; mso-no-proof: yes;">Data Source=P06-INF-WS-1\SQLEXPRESS;Database=DB1;User ID=sa;Password=sa</span></div><div class="MsoNormal" style="margin: 0cm 0cm 10pt 18pt;"><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%; mso-no-proof: yes;">select * from Table1 tb1 join on DB2.dbo.Table2 tb1 where </span></div><div class="MsoNormal" style="margin: 0cm 0cm 10pt 18pt;"><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%; mso-no-proof: yes;">tb1.id=tb2.id</span></div><div class="MsoNormal" style="margin: 0cm 0cm 10pt 18pt;"><span style="font-family: "Times New Roman", "serif"; font-size: 12pt; line-height: 115%; mso-no-proof: yes;">Table1 is assumed to be in DB1 as its specified in the connection string</span></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3329736017315021535.post-89597300888316217742010-10-31T03:17:00.001-07:002010-10-31T03:17:06.348-07:00Ever wondered why Code coverage shows not enabled for the code1.Creating a test class for your project<br />
<br />
Create a test class only when you have completed your coding bc the test class are created based<br />
on your business logic..hence if you add/remove any functions there it wont be reflected in your test<br />
class.<br />
<br />
a.Go to Test->New Test in VS.Select Unit test Wizard and give it a appropriate name.All the test<br />
functions wil be autogenerated for you.<br />
<br />
b.Right click on solution and select add new file.Select Test Run Configuration in the general tab.<br />
<br />
This file will end with .testrunconfig wherein you can specify different rules for your test to run.<br />
<br />
If you want to check how much coverage you have achieved open this file and select Code Coverage-<br />
<br />
Check the files for which you want to see the coverage.<br />
<br />
c.Check if a .vsmdi file is created . if not then goto Test->Select Active Test Run configuration and<br />
select the file you want to associate.<br />
<br />
You can have many .testrunconfig files and associate them to a .vsmdi file which will be picked up by<br />
you test class.<br />
<br />
c. After writing all the test class select test->Run->All Test in solution. Remember to run test rather<br />
then just clicking F5<br />
<br />
d.Click on test->Windows->Code coverage Results.<br />
<br />
You can see the code coverage only if all your test case are passed.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3329736017315021535.post-10214023367794477872010-10-31T03:15:00.002-07:002010-10-31T03:15:53.668-07:00Schedule deleting of files of previous day in a particular folder<span style="font-size: large;"><b>Schedule deleting of files of previous day in a particular folder</b></span><br />
<br />
Although this can be achieved using .bat files i find it very complex.<br />
Hence my approach is to write a vbscript and schedule it to run everyday at<br />
particular time.<br />
<br />
//VBScript code<br />
<br />
Option Explicit<br />
<br />
On Error Resume Next<br />
<br />
Dim oFSO, oFolder, sDirectoryPath<br />
<br />
Dim oFileCollection, oFile, sDir<br />
<br />
Dim iDaysOld<br />
<br />
'Specify Directory Path From Where You want to clear the old files<br />
<br />
sDirectoryPath = ""<br />
<br />
Set oFSO = CreateObject("Scripting.FileSystemObject")<br />
<br />
Set oFolder = oFSO.GetFolder(sDirectoryPath)<br />
<br />
Set oFileCollection = oFolder.Files<br />
<br />
For each oFile in oFileCollection<br />
<br />
iDaysOld =datediff("d",oFile.DateLastModified,date())<br />
<br />
If iDaysOld>0 Then<br />
<br />
oFile.Delete(True)<br />
<br />
End If<br />
<br />
Next<br />
<br />
Set oFSO = Nothing<br />
<br />
Set oFolder = Nothing<br />
<br />
Set oFileCollection = Nothing<br />
<br />
Set oFile = Nothing<br />
<br />
Steps to schedule it via schedular in windows 7-<br />
<br />
1.Go to Administrative Tools->Task Schedular.<br />
<br />
2.create new task.Give it a name in General Tab.<br />
<br />
3.In the trigger tab set the schedule it to occur daily at a particular<br />
time.<br />
<br />
4.In Action tab give the path where the .vbs is stored.<br />
<br />
5.In the settings tab click “Run task as soon as possible after a scheduled<br />
start is missed”.<br />
<br />
Commonly encountered problems-<br />
<br />
1.What if the system is logged of for days ..<br />
<br />
Solution: Either active the notication facility in task schedular and<br />
delete the files manually or<br />
<br />
Create one more task indicating that the .vbs should run whenver the user<br />
logs into the system.<br />
<br />
2.what if the user has stord some files today in that path and logged<br />
of...when he logs in again wouldnt that folders get deleted—<br />
<br />
Solution: No the code is such that it will delete only files from previous<br />
days.So even if schdule is missed the second task will delete the files.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-3329736017315021535.post-9456763653386907542010-10-31T03:15:00.000-07:002010-10-31T03:15:07.720-07:00Replace multiple values in a string<span style="font-size: large;"><b>Replace multiple values in a string</b></span><br />
<br />
using System.Text.RegularExpressions;<br />
<br />
string Name=”India’an/dt/heWorl’d”;<br />
//specify the characters to be replaced.here it will be replaced by blank<br />
Regex.Replace(actualvalue[0].Trim(), @"[/,’ ]"," ").ToString()<br />
<br />
Ouput- India an dt heWorl dUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-3329736017315021535.post-72171652693807470112010-10-31T03:13:00.001-07:002010-10-31T03:13:54.178-07:00Split a string based on first occurrence of character<span style="font-size: large;"><b>Split a string based on first occurrence of character</b></span><br />
<br />
Suppose you have a string wherein a particular character is repeated many times but u want to split<br />
it only at the first occurance<br />
<br />
String value=”Name:Chaithra:Age-10”<br />
<br />
string[] actualValue = value.Split(new char[] { ':' }, 2);<br />
<br />
output-<br />
actualValue[0]= Name<br />
//observe that it has not split again.<br />
<br />
actualValue[1]= Chaithra:Age-10Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-3329736017315021535.post-23554528981256994312010-09-21T07:31:00.001-07:002010-09-21T07:36:21.872-07:00State Management<div style="font-family: Georgia,"Times New Roman",serif;"><b>1.What is state management in asp.net ?</b></div><span style="font-family: Georgia,"Times New Roman",serif;">asp.net is a stateless technology.The process of maintaining the contents of the page when it moves from on page to another or when it is sent to the server is called state management.it can be done in two ways-</span><br />
<div style="font-family: Georgia,"Times New Roman",serif;">a)In-proc</div><span style="font-family: Georgia,"Times New Roman",serif;">b)out-proc</span>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-3329736017315021535.post-8647735065054149012010-09-20T20:06:00.000-07:002010-09-21T20:55:48.020-07:00LINQ<b><span style="font-family: Georgia,"Times New Roman",serif;">1.What is LINQ ?</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">LINQ stands for language integrated query. Its a part of .Net 3.5 framework.It provides quering capabilities in .Net languages.it intergrates databse model into programming model.logic can be used to retrieve data with sql like statements in C#.</span><br />
<br />
<b><span style="font-family: Georgia,"Times New Roman",serif;">2.What are diff area in which LINQ can be used ?</span></b><br />
<b><span style="font-family: Georgia,"Times New Roman",serif;">LINQ is divided into 3 categories --</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">a)linq to objects--this includes mainly quering collections which implemet IEnumerable interface. </span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">b)linq to ADO.NET</span><br />
<ul><li><span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;"> </span></span><span style="font-family: Georgia,"Times New Roman",serif;">linq </span><span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;">to SQL</span></span><span style="font-family: Georgia,"Times New Roman",serif;"> </span></li>
<li><span style="font-family: Georgia,"Times New Roman",serif;"> </span><span style="font-family: Georgia,"Times New Roman",serif;">linq </span><span style="font-family: Georgia,"Times New Roman",serif;">to DataSet</span></li>
<li><span style="font-family: Georgia,"Times New Roman",serif;"> </span><span style="font-family: Georgia,"Times New Roman",serif;">linq </span><span style="font-family: Georgia,"Times New Roman",serif;">to Entities(ORM model)</span></li>
</ul><span style="font-family: Georgia,"Times New Roman",serif;">c)</span><span style="font-family: Georgia,"Times New Roman",serif;">linq </span><span style="font-family: Georgia,"Times New Roman",serif;">to XML </span><br />
<br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b>3.When not to use LINQ ? </b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">a)It should not be used in C# if the same logic is achieved by simple c# coding. </span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">b)linq to sql involves performance overhead hence should be used efficiently.</span><br />
<br />
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;"><b>4.Use LINQ to query the numbers greater than 5 from a collection of array.</b>int[] nums = new int[] {0,4,2,6,3,8,3,1}; <br />
var result = from n in nums<br />
where n > 5<br />
orderby n //orders in asc order<br />
select n; <b><br />
<br />
5. What is ORM ?</b><br />
it stands for object relational mapping wherein it provides the user with the ability to change and manipulate the objects without having to worry about how the objects are related to their datasource. <b><br />
</b></span></span><br />
<br />
<pre class="csharp"><span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-family: Georgia,"Times New Roman",serif;"> </span></span></pre>Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-3329736017315021535.post-87757546334826391612010-09-20T18:34:00.001-07:002010-09-20T18:34:52.319-07:00Answer a Ques !!!<b><span style="font-family: Georgia,"Times New Roman",serif;">1.Why C# does not support multiple inheritance ?</span></b>Unknownnoreply@blogger.com6tag:blogger.com,1999:blog-3329736017315021535.post-55476136076020718212010-09-19T19:28:00.001-07:002010-09-20T00:31:26.885-07:00Polymorphism<b><span style="font-family: Georgia,"Times New Roman",serif;">1..What is Polymorphism.explain diff types.</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Ability to take more than one form is called poymorphism.Diff types are-</span><br />
<div style="font-family: Georgia,"Times New Roman",serif;"><i>Compile time/Design time polymorphism </i></div><div style="font-family: Georgia,"Times New Roman",serif;">this is also called method overloading.The method will have same name but diff parameters.</div><div style="font-family: Georgia,"Times New Roman",serif;"><i>Run time polymorphism</i></div><span style="font-family: Georgia,"Times New Roman",serif;">this is also called overriding.its achieved by virtual and override keywords </span><br />
<br />
<b><span style="font-family: Georgia,"Times New Roman",serif;">2.What is method overloading ?</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Having different methods with same name but different parameters inn a single class is called method overloading.methods can be overloaded based on following-</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">a)diff no of paramteres.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"> public void method(int a)</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"> public void method(int a,int b)</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">b)diff types of parameters.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"> </span><span style="font-family: Georgia,"Times New Roman",serif;"> public void method(int a)</span><br />
public void method(float a)<br />
<span style="font-family: Georgia,"Times New Roman",serif;">c)diff order of parameters.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"> </span><span style="font-family: Georgia,"Times New Roman",serif;">public void method(int a,float b)</span> <br />
<span style="font-family: Georgia,"Times New Roman",serif;">public void method(float b,int a)</span><br />
<br />
<div style="font-family: Georgia,"Times New Roman",serif;"><b>3.When should we use method overloading?</b></div><div style="font-family: Georgia,"Times New Roman",serif;">When you need couple of methods to take different parameters but do the same thing.</div><div style="font-family: Georgia,"Times New Roman",serif;">eg-Draw(circle c),Draw(triangle t)... the basic function is drawing but they draw diff structures. in CLR console.writeline() does the same thing.</div><br />
<div style="font-family: Georgia,"Times New Roman",serif;"><b>4.What is method overriding?</b></div><div style="font-family: Georgia,"Times New Roman",serif;">Its a feature which is used in inheritance chain and it provides its own implementation to an already existing method in base class. its achived by using virtual and override keyword.</div><div style="font-family: Georgia,"Times New Roman",serif;">class A</div><div style="font-family: Georgia,"Times New Roman",serif;">{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public <b>virtual </b>void method()</div><div style="font-family: Georgia,"Times New Roman",serif;"> {</div><div style="font-family: Georgia,"Times New Roman",serif;"> } </div><div style="font-family: Georgia,"Times New Roman",serif;">} </div><div style="font-family: Georgia,"Times New Roman",serif;">class B:A</div><div style="font-family: Georgia,"Times New Roman",serif;">{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public <b>override </b>void method() </div> {<br />
} <br />
}<br />
<span style="font-family: Georgia,"Times New Roman",serif;">The appropriate methods are invoked at runtime when proper references are allocate</span>d.<br />
<br />
<div style="font-family: Georgia,"Times New Roman",serif;"><b>5.Advantages of polymorphism.</b></div><span style="font-family: Georgia,"Times New Roman",serif;">a)invoking child class functions dynamically</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">b)maintenance of code becomes easy.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><br />
<b>6.Whats the diff bt new and override keyword in inheritance chain ?</b></span><br />
<div style="font-family: Georgia,"Times New Roman",serif;">new keyword completely hides the base class implementation and creates a<br />
new method.It can be concluded that the method defined is independent of<br />
base class method.</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><span style="font-family: Georgia,"Times New Roman",serif;">override keyword overrides the base class implementation. it helps in existence of different diff versions of method and appropriate version is called dynamically.Objects of derived class will cal this method instead of base class method.</span><br />
<div style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b></div><b><span style="font-family: Georgia,"Times New Roman",serif;">7.Will the foll code compile ? why ?</span></b><br />
<b><span style="font-family: Georgia,"Times New Roman",serif;">a) </span></b><br />
<div style="font-family: Georgia,"Times New Roman",serif;">class A</div><div style="font-family: Georgia,"Times New Roman",serif;">{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public void method()</div><div style="font-family: Georgia,"Times New Roman",serif;"> {</div><div style="font-family: Georgia,"Times New Roman",serif;"> } </div><div style="font-family: Georgia,"Times New Roman",serif;">} </div><div style="font-family: Georgia,"Times New Roman",serif;">class B:A</div><div style="font-family: Georgia,"Times New Roman",serif;">{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public <b>override </b>void method() </div><div style="font-family: Georgia,"Times New Roman",serif;"> {</div><div style="font-family: Georgia,"Times New Roman",serif;"> } </div>} <br />
<div style="font-family: Georgia,"Times New Roman",serif;">No.Because you can override the base class method only if its marked as virtual</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><b>b)</b></div><div style="font-family: Georgia,"Times New Roman",serif;">class A</div><div style="font-family: Georgia,"Times New Roman",serif;">{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public void method()</div><div style="font-family: Georgia,"Times New Roman",serif;"> {</div><div style="font-family: Georgia,"Times New Roman",serif;"> } </div><div style="font-family: Georgia,"Times New Roman",serif;">} </div><div style="font-family: Georgia,"Times New Roman",serif;">class B:A</div><div style="font-family: Georgia,"Times New Roman",serif;">{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public <b>new </b>void method() </div><div style="font-family: Georgia,"Times New Roman",serif;"> {</div><div style="font-family: Georgia,"Times New Roman",serif;"> } </div>}<br />
<span style="font-family: Georgia,"Times New Roman",serif;">Yes.Because new keyword defines its own implementation and its not related to base class method in any way.</span><br />
<br />
<b><span style="font-family: Georgia,"Times New Roman",serif;">c)</span></b><br />
<div style="font-family: Georgia,"Times New Roman",serif;">class A</div><div>{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public void method(ref int a)</div><div style="font-family: Georgia,"Times New Roman",serif;"> {</div><div> }<br />
<span style="font-family: Georgia,"Times New Roman",serif;">public void method(out int a)</span> <br />
<div style="font-family: Georgia,"Times New Roman",serif;"> {</div><div> }</div></div><div style="font-family: Georgia,"Times New Roman",serif;">}<br />
No.methods cannot be overloaded based on the ref and out parameter.<br />
<br />
<b>d)</b><br />
<div style="font-family: Georgia,"Times New Roman",serif;">class A</div><div>{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public <b>virtual </b>void method()</div><div style="font-family: Georgia,"Times New Roman",serif;"> {</div><div> } </div><div style="font-family: Georgia,"Times New Roman",serif;">} </div><div style="font-family: Georgia,"Times New Roman",serif;">class B:A</div><div>{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public void method() </div><div> {</div><div style="font-family: Georgia,"Times New Roman",serif;"> } </div>}<br />
<div style="font-family: Georgia,"Times New Roman",serif;">class C:B</div><div>{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public <b>override </b>void method() </div><div> {</div><div style="font-family: Georgia,"Times New Roman",serif;"> } </div>}<br />
No.Class C is overriding method in its base class B. it can do so only if method in base class is marked as virtual.<br />
<br />
<b>e)</b><br />
<div style="font-family: Georgia,"Times New Roman",serif;">class A</div><div>{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public virtual void method()</div><div> {</div><div> } </div><div style="font-family: Georgia,"Times New Roman",serif;">} </div><div style="font-family: Georgia,"Times New Roman",serif;">class B:A</div><div>{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public new void method() </div><div> {</div><div style="font-family: Georgia,"Times New Roman",serif;"> } </div>}<br />
<div style="font-family: Georgia,"Times New Roman",serif;">class C:B</div><div>{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public override void method() </div><div> {</div><div style="font-family: Georgia,"Times New Roman",serif;"> } </div>} <br />
<br />
No.Class C is overriding method in its base class B. it can do so only if method in base class is marked as virtual.<br />
<br />
<b>8.Whats the disadvantage of using virtual keyword?</b><br />
a)Appropriate function calls are determined only at runtime.<br />
b)since virtual keyword is used derived classes may ignore that base class implementations.<br />
<br />
<b>9.Whats the output of foll code</b><br />
a)<br />
<div style="font-family: Georgia,"Times New Roman",serif;">class A</div><div>{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public virtual void method()</div><div> {<br />
//print A </div><div> } </div><div style="font-family: Georgia,"Times New Roman",serif;">} </div><div style="font-family: Georgia,"Times New Roman",serif;">class B:A</div><div>{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public override void method() </div><div> {<br />
//print B </div><div style="font-family: Georgia,"Times New Roman",serif;"> } </div>}<br />
<div style="font-family: Georgia,"Times New Roman",serif;">class C:B</div><div>{</div><div style="font-family: Georgia,"Times New Roman",serif;"> public new void method() </div><div> {<br />
//Print C </div><div style="font-family: Georgia,"Times New Roman",serif;"> } </div>}<br />
A objA = new A();<br />
objA .method() //<b>Output</b>:A<br />
<br />
objB= new B()<br />
objB.method() //<b>Output</b>:B<br />
<br />
objC= new C()<br />
objC.method() //<b>Output</b>:B(bc of new keyword) <br />
<br />
<br />
<b>10.Why static methods cannot have virtual keyword ?</b><br />
The idea of using virtual keyword is to achieve polymorphism i.e calling appropriated functions dynamically at runtime, But static methods are attached to the class names and to invoke them you have to go through the classes. And they are decided at compile time hence there is no point in having virtual keyword to static methods.<br />
<br />
<b>11.Can properties be marked as virtual ?</b><br />
Yes <br />
<br />
<br />
<br />
<br />
<br />
</div><span style="font-family: Georgia,"Times New Roman",serif;"> </span>Unknownnoreply@blogger.com24tag:blogger.com,1999:blog-3329736017315021535.post-36169055385096467892010-09-14T21:07:00.000-07:002010-09-16T22:55:13.380-07:00Diff bet ween== and Equals ?<div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-family: Georgia,"Times New Roman",serif;">In our daily programming we have come across these expressions many times. here is when you should choose one over the other.</span>Both these operator perform the same function i.e comparing the equality but the way they do it depends on who is using them.</div><div style="font-family: Georgia,"Times New Roman",serif;">For <i>value types</i> both == and Equals mean the same ,they compare the value present in both the types.eg</div><div style="font-family: Georgia,"Times New Roman",serif;"> int a=5;int b=5;</div><div style="font-family: Georgia,"Times New Roman",serif;"> a==b</div><div style="font-family: Georgia,"Times New Roman",serif;"> a.equlas(b) </div><div style="font-family: Georgia,"Times New Roman",serif;">Both these return True as they are comparing the value inside them and both the variables have same value.</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;">For <i>Reference types </i>== checks whether they are pointing to the same reference and equals checks if both the reference contains the same value.</div><div style="font-family: Georgia,"Times New Roman",serif;">eg:</div><div style="font-family: Georgia,"Times New Roman",serif;"> </div><div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">StringBuilder s1 = new StringBuilder(“Name”);</div><div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">StringBuilder s2 = new StringBuilder(“Name”);<o:p> </o:p></div><div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">Console.WriteLine(s1 == s2);</div><div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">Console.WriteLine(s1.Equals(s2));<br />
<o:p> </o:p></div><div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">Will display:</div><div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">False</div><span style="font-family: Georgia,"Times New Roman",serif;">True</span><br />
<div style="font-family: Georgia,"Times New Roman",serif;"></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3329736017315021535.post-15886563963613546782010-09-07T22:52:00.000-07:002010-09-07T22:52:24.416-07:00String Manipulation1.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3329736017315021535.post-90060151348532144762010-09-06T04:34:00.000-07:002010-09-20T00:42:50.257-07:00Inheritance<b><span style="font-family: Georgia,"Times New Roman",serif;"> 1.what is inheritance ?</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif; font-size: small;">The method of constructing one class from another is called Inheritance.The derived class inherits all the properties and methods from the base class and it can add its own methods also.</span><br />
<br />
<div style="font-family: Georgia,"Times New Roman",serif;"><b>2.Are constructors and destructors inherited ?</b></div>No<br />
<br />
<b><span style="font-family: Georgia,"Times New Roman",serif;">3.Advantages of Inheritance.</span></b><br />
<div style="font-family: Georgia,"Times New Roman",serif;">a)Code re usability-Public and protected methods can be used in derived classes</div><span style="font-family: Georgia,"Times New Roman",serif;">b) Extensibility- base class can be extended as per business logic in derived classes.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">c)Polymorphism</span><br />
<br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b>4.What are diff types of inheritance?</b></span><br />
<i><span style="font-family: Georgia,"Times New Roman",serif;">a) Single inheritance<b> --</b></span></i><span style="font-family: Georgia,"Times New Roman",serif;">Class B is derived from base class A.</span><i><span style="font-family: Georgia,"Times New Roman",serif;"><b> A->B</b></span></i><br />
<i><span style="font-family: Georgia,"Times New Roman",serif;">b)Multiple inheritance ---Class C derives from both A and B. <b>A,B->C</b></span></i><br />
<i><span style="font-family: Georgia,"Times New Roman",serif;">c)Multilevel inheritance--</span></i><i><span style="font-family: Georgia,"Times New Roman",serif;">Class B derives from Class base class A.class C derives from B. <b>A->B->C </b></span></i><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><i>d)Hybrid inheritance --class B and C derives from same base class A. <b>A->B,C</b></i></span><br />
<br />
<b><span style="font-family: Georgia,"Times New Roman",serif;">5.Is multiple inheritance possible in C#.Why?</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">No. because</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">a)Its not supported by CLR since its support many diff language and not all languages can have multiple inheritance concept. </span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">b)Because of the complexities involved where method name can clash when two diff classes have same method name.This is resolved by pointers in C++ but its not possible in c#.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><br />
</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Instead interfaces can be used to achieve the same.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><br />
</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b>6.Is circular inheritance possible. like A:B ,B:A ?</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">No</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><i><br />
</i></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b>7.How do you prevent a class from being inherited ?</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">a)Make the class as sealed.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">b)Add private constructors to the class.<b><br />
</b></span><br />
<br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b>8. Can derive class have public modifier when there are no modifiers specified on the base class?</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">No. bc derived class cannot be more accessible that base class.</span><br />
<br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b> </b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b>9.why c# does not support inheritance by structure?</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Because structures are mainly used for light weight process. And if they are allowed to be inherited then they have to act as base class which is not possible as they are value types.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b>10.Does structs inherit from interfaces?</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Yes structs can inherit only from interface.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b>11.What do you mean by sealed keyword ?</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">If you mark a class as sealed it means that you cannot inherit from it but you can create objects of that class.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b>12.can you mark method as sealed ?</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Yes.But for a method to be marked as sealed you need to have override keyword also.<b><br />
</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b>13.what do you mean by upcasting and downcasting ?</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">class DerivedClass :BaseClass<b><br />
</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><i>Upcasting--</i>assigning a derived class object to a base class.This is implicit.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">BaseClass b= new DerivedClass.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Downcasting--assigning baseclass object to derived class. This is explicit and it throws run time error .</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">a)BaseClass b = new BaseClass()</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"> DerivedClass d= b //will give compile time error.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"> </span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">b) d=(DerivedClass)b //will give runtime error.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><br />
</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">c)b=d;</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"> d=(DerivedClass)b;</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"> d.method() //will always call derivedclass method<b><br />
</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b> </b>//there is no point in taking so much of pain and using this kind of code !!!</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b>14.<br />
</b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b> </b><i><br />
</i></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><i><b> </b></i> </span>Unknownnoreply@blogger.com20tag:blogger.com,1999:blog-3329736017315021535.post-5902860477017187062010-09-02T05:53:00.000-07:002011-01-16T22:49:16.563-08:00Exception<div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><b>1.What are the two diff types of error?</b></span></div><div style="font-family: Verdana,sans-serif;">Run time error and Compile time error</div><div style="font-family: Verdana,sans-serif;"><br />
</div><div style="font-family: Verdana,sans-serif;"><b>2.What is the base class from which all the exceptions are derived ?</b></div><div style="font-family: Verdana,sans-serif;">System.Exception class</div><div style="font-family: Verdana,sans-serif;"><br />
</div><div style="font-family: Verdana,sans-serif;"><b>3.What are the two main kind of exceptions class?</b></div><div style="font-family: Verdana,sans-serif;"><i>System Exception</i>-- Mainly used for inbuilt exceptions like Null Ref Exception,Overflow Exception,Argument ....etc</div><div style="font-family: Verdana,sans-serif;"><i>Application Exception</i>-This class is used for user defined exceptions. </div><div style="font-family: Verdana,sans-serif;"><br />
</div><div style="font-family: Verdana,sans-serif;"><b>4.How to you handle error in C#?</b><br />
By using try ,catch and finally blocks.<br />
<i>try</i>-contains the code which might throw an exception<br />
<i>catch</i>-deals with various error conditions<br />
<i>finally</i>-does the cleaning up.<br />
<br />
<b>5.Does finally get executed if the code throws an error ?</b><br />
Finally is always executed.<br />
<br />
<b>6.Is it mandatory for a piece of code to have catch or finally when try block is there ?</b><br />
Yes. If a try block is there then either catch or finally has to be there or else a compiler error is generated.<br />
<br />
<b>7.Can finally bock have return statement ?</b><br />
No,a compile time error is generated. Thats bc finally contains the clean up code.<br />
<br />
<b>8.Can there be many catch statements for a single try block ?</b><br />
Yes.But the rule is most specific exceptions should be caught first.<br />
<br />
<b>9.Will the foll code compile ?</b><br />
<b> </b> try <br />
{<br />
throw new SystemException();<br />
} <br />
catch(Exception e)<br />
{<br />
}<br />
catch(ArgumentException e)<br />
{<br />
}<br />
No.It gives the foll error<br />
A previous catch clause already catches all exceptions of this or of a super type ('System.Exception')<br />
<br />
<b>10.Whats the syntax for catching all kinds of exception.</b><br />
try{}<br />
catch //no parameters specified<br />
{<br />
}<br />
it will catch exceptions thrown by managed as well as unmanaged code<b>.</b><br />
<b><br />
</b><br />
<b>11.All the foll catch block uses the same exception parameter 'e'. Is it valid?</b><br />
catch(Exception e) {}<br />
catch(ArgumentException e) {} <br />
Yes,bc the parameter passed to catch block wil be within its scope only.<br />
<b><br />
</b><br />
<b>12.What are diff exception properties ?</b><br />
a)Helplink-- provide link to help files which give more info on the exception raised.<br />
<br />
b)<i>Message</i>--gives the text that describes the exception.<br />
Suppose catch(Exception e)<br />
{<br />
throw new Exception("Failure")<br />
}<br />
then e.Message will give output as "Failure".<br />
<br />
c)<i>Source</i>--provides the name of assembly from where exception is raised.<br />
d)<i>Target Site</i>--name of method thats trows an error<br />
e)<i>Stack Trace</i>--provides stack flow of the exception.<br />
f)<i>Inner Exception</i>--When exception is thrown from one catch to another the message from first catch is passed as inner exception to second catch.<br />
<br />
<b>13.What is checked and unchecked operator.</b><br />
<i>checked</i>--checks for the error and throws an exception.<br />
<i>unchecked</i>--does not check for the error .truncates the data and prints it..used mainly while casting.<br />
<br />
<b>14.Does foll code work ?</b><br />
try {}<br />
catch(Exception e) {}<br />
catch(Exception e) {}<br />
<br />
No,two catch block cannot have same exception classes.<br />
<br />
<b> 15.Whats the diff bt throw and throw e ?</b><br />
<i>throw</i>-- throws the exception.<br />
throw is internally compiled to rethrow <br />
<i>throw e</i>--throws the exception and resets the stack trace to current catch<br />
location.<b><br />
</b><br />
internally compiled to throw which taken an exception parameter as<br />
input.<br />
<br />
<b>16.What is the output of foll programs </b><br />
a) try <br />
{<br />
throw new SystemException("This is wrong");<br />
}<br />
catch(Exception e)<br />
{<br />
Console.WriteLine(e.Message); <br />
return;<br />
}<br />
finally<br />
{<br />
Console.WriteLine("i am inside finally");<br />
Console.Read();<br />
}<br />
<br />
<b>output</b>-- This is wrong<br />
i am inside finally.<br />
<br />
b) try <br />
{<br />
throw new SystemException("This is wrong");<br />
}<br />
catch(Exception e)<br />
{<br />
Console.WriteLine(e.Message);<br />
throw;<br />
}<br />
finally<br />
{<br />
Console.WriteLine("i am inside finally");<br />
Console.Read();<br />
}<br />
<br />
<b>output </b>- This is wrong.<br />
Application crashes bc the throw is not being caught anywhere and<br />
hence finally wont be executed.<br />
<br />
c)public class A <br />
<br />
{<br />
public void methodA() <br />
{<br />
try <br />
{<br />
B test = new B();<br />
test.methodB();<br />
} <br />
catch (Exception e) <br />
{<br />
throw e;<br />
Console.WriteLine("Exception from Class A");<br />
}<br />
finally <br />
{<br />
Console.WriteLine("Inside Class A Finally");<br />
}<br />
}<br />
}<br />
<br />
public class B <br />
{<br />
public void methodB() <br />
{<br />
try <br />
{<br />
throw new Exception("Exception from Class B");<br />
} <br />
catch (Exception e) <br />
{<br />
throw;<br />
Console.WriteLine("Exception from Class A");<br />
} <br />
finally <br />
{<br />
Console.WriteLine("Inside Class B Finally");<br />
}<br />
}<br />
}<br />
<br />
output--inside class B finally.<br />
<br />
<br />
<u><b>Not able to see the line number in exception stack trace in remote machine</b></u><br />
<br />
While building a project make sure .pdb files are generated. copy these files in the folder where you have installed your application in remote machine .<br />
If pdb files are not generated check if the setting is enabled for your project-<br />
<br />
Solution->Properties->Build->Advanced Build Settings->Debug Info->pdb-only</div><div style="font-family: Verdana,sans-serif;"><br />
<!--[if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:RelyOnVML/> <o:AllowPNG/> </o:OfficeDocumentSettings> </xml><![endif]--><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>EN-SG</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:DontVertAlignCellWithSp/> <w:DontBreakConstrainedForcedTables/> <w:DontVertAlignInTxbx/> <w:Word11KerningPairs/> <w:CachedColBalance/> <w:UseFELayout/> </w:Compatibility> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="--> <m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent><!--[endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/> <w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/> <w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/> <w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/> <w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/> <w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/> <w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/> <w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/> <w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/> <w:LsdException Locked="false" Priority="37" Name="Bibliography"/> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
</style> <![endif]--> </m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac><br />
<div class="MsoNormal" style="margin-left: 18pt;"><b><u><span style="font-size: 14pt; line-height: 115%;"><br />
</span></u></b></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<b><br />
</b><br />
<b><br />
</b><br />
<b></b><br />
<b></b><br />
<b></b><br />
<b></b><br />
<b><br />
</b><br />
<b><br />
</b><br />
<br />
</div>Unknownnoreply@blogger.com10tag:blogger.com,1999:blog-3329736017315021535.post-82955368408599656402010-09-01T04:21:00.001-07:002010-09-21T22:39:54.865-07:00SQL<div class="separator" style="clear: both; text-align: center;"><span id="goog_1528623305"></span><span id="goog_1528623306"></span></div><b><span style="font-family: Georgia,"Times New Roman",serif;"> 1.How do you create a table in SQl ?</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Create</span><span style="font-family: Georgia,"Times New Roman",serif;"> table <table name> (<column name1> <datatype>,</span><span style="font-family: Georgia,"Times New Roman",serif;"><column name2> <datatype>)</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Create table A (Name varchar(20),Age int)</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;"><br />
</span><br />
<b><span style="font-family: Georgia,"Times New Roman",serif;">2.</span></b><b><span style="font-family: Georgia,"Times New Roman",serif;"> How do you add new column to a table?</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Alter table <tablename> add <columnname> <datatype> </span><b><span style="font-family: Georgia,"Times New Roman",serif;"><br />
</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Alter table A Add Location varchar(20).</span><b><span style="font-family: Georgia,"Times New Roman",serif;"></span></b><br />
<b><span style="font-family: Georgia,"Times New Roman",serif;"><br />
</span></b><br />
<b><span style="font-family: Georgia,"Times New Roman",serif;">3.How do you remove a column from a table?</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Alter table <tablename> drop coulmn </span><span style="font-family: Georgia,"Times New Roman",serif;"><columnname></span><b><span style="font-family: Georgia,"Times New Roman",serif;"> </span></b><br />
Alter table A drop column Location.<br />
<b><br />
</b><br />
<div style="font-family: Georgia,"Times New Roman",serif;"><b>4.Diff bt Drop ,Delete and Truncate.</b></div><meta content="text/html; charset=utf-8" http-equiv="Content-Type"></meta><meta content="Word.Document" name="ProgId"></meta><meta content="Microsoft Word 12" name="Generator"></meta><meta content="Microsoft Word 12" name="Originator"></meta><link href="file:///C:%5CUsers%5CNAVEEN%7E1%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml" rel="File-List"></link><link href="file:///C:%5CUsers%5CNAVEEN%7E1%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx" rel="themeData"></link><link href="file:///C:%5CUsers%5CNAVEEN%7E1%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml" rel="colorSchemeMapping"></link> <m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent><style>
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;
mso-font-charset:1;
mso-generic-font-family:roman;
mso-font-format:other;
mso-font-pitch:variable;
mso-font-signature:0 0 0 0 0 0;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:-1610611985 1073750139 0 0 159 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-parent:"";
margin-top:0in;
margin-right:0in;
margin-bottom:10.0pt;
margin-left:0in;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
.MsoChpDefault
{mso-style-type:export-only;
mso-default-props:yes;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
.MsoPapDefault
{mso-style-type:export-only;
margin-bottom:10.0pt;
line-height:115%;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style> </m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac><br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: medium none;"><tbody>
<tr style="height: 15.2pt;"> <td style="border: 1pt solid black; height: 15.2pt; padding: 0in 5.4pt; width: 115.3pt;" valign="top" width="154"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><b>Drop<o:p></o:p></b></div></td> <td style="border-color: black black black -moz-use-text-color; border-style: solid solid solid none; border-width: 1pt 1pt 1pt medium; height: 15.2pt; padding: 0in 5.4pt; width: 115.3pt;" valign="top" width="154"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><b>Trucate<o:p></o:p></b></div></td> <td style="border-color: black black black -moz-use-text-color; border-style: solid solid solid none; border-width: 1pt 1pt 1pt medium; height: 15.2pt; padding: 0in 5.4pt; width: 115.3pt;" valign="top" width="154"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><b>Delete<o:p></o:p></b></div></td> </tr>
<tr style="height: 0.2in;"> <td style="border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; height: 0.2in; padding: 0in 5.4pt; width: 115.3pt;" valign="top" width="154"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">DDL Commands<o:p></o:p></div></td> <td style="border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 0.2in; padding: 0in 5.4pt; width: 115.3pt;" valign="top" width="154"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">DDL commands<o:p></o:p></div></td> <td style="border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 0.2in; padding: 0in 5.4pt; width: 115.3pt;" valign="top" width="154"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">DML command<o:p></o:p></div></td> </tr>
<tr style="height: 15.2pt;"> <td style="border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; height: 15.2pt; padding: 0in 5.4pt; width: 115.3pt;" valign="top" width="154"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">No Rollback possible<o:p></o:p></div></td> <td style="border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 15.2pt; padding: 0in 5.4pt; width: 115.3pt;" valign="top" width="154"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">No Rollback possible<o:p></o:p></div></td> <td style="border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 15.2pt; padding: 0in 5.4pt; width: 115.3pt;" valign="top" width="154"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">Can be rolled back<o:p></o:p></div></td> </tr>
<tr style="height: 15.2pt;"> <td style="border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; height: 15.2pt; padding: 0in 5.4pt; width: 115.3pt;" valign="top" width="154"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">Drops the complete table along with structure and data<o:p></o:p></div></td> <td style="border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 15.2pt; padding: 0in 5.4pt; width: 115.3pt;" valign="top" width="154"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">Removes the data<o:p></o:p></div></td> <td style="border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 15.2pt; padding: 0in 5.4pt; width: 115.3pt;" valign="top" width="154"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">Removes the data<o:p></o:p></div></td> </tr>
<tr style="height: 15.2pt;"> <td style="border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; height: 15.2pt; padding: 0in 5.4pt; width: 115.3pt;" valign="top" width="154"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">Drops complete table<o:p></o:p></div></td> <td style="border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 15.2pt; padding: 0in 5.4pt; width: 115.3pt;" valign="top" width="154"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">Drops complete table<o:p></o:p></div></td> <td style="border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 15.2pt; padding: 0in 5.4pt; width: 115.3pt;" valign="top" width="154"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">Selective deletion is possible<o:p></o:p></div></td> </tr>
</tbody></table> <b><br />
</b><b><span style="font-family: Georgia,"Times New Roman",serif;"> 5.Select all the students whose age is between 10 to 15.</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Student(Name,Age) </span><b><span style="font-family: Georgia,"Times New Roman",serif;"><br />
</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">select name from Student where Age between 10 and 15</span><b><span style="font-family: Georgia,"Times New Roman",serif;"></span></b><br />
<b><span style="font-family: Georgia,"Times New Roman",serif;"><br />
</span></b><br />
<b><span style="font-family: Georgia,"Times New Roman",serif;">6.Diff bt Primary Key and Unique Key.</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Both are used to uniquely identify rows </span><b><span style="font-family: Georgia,"Times New Roman",serif;"><br />
</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Primary Key-Cannot be null,Only one primary key can exist in a table</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Unique Key-can be null</span><b><span style="font-family: Georgia,"Times New Roman",serif;">,</span></b><span style="font-family: Georgia,"Times New Roman",serif;">can have more than one unique key in table</span><b><span style="font-family: Georgia,"Times New Roman",serif;">.</span></b><br />
<b><span style="font-family: Georgia,"Times New Roman",serif;"><br />
</span></b><br />
<b><span style="font-family: Georgia,"Times New Roman",serif;">7.Whats the diff bt having and where clause?</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Where -used in all DML statements.used only with group by function</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Having -used with aggregate or group.can be used only with SELECT </span><b><span style="font-family: Georgia,"Times New Roman",serif;"></span></b><br />
<b><span style="font-family: Georgia,"Times New Roman",serif;"><br />
</span></b><br />
<b><span style="font-family: Georgia,"Times New Roman",serif;">8.How to you copy large data to SQL Server?</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Using a tool called Bulk Copy.</span><b><span style="font-family: Georgia,"Times New Roman",serif;"></span></b><br />
<b><span style="font-family: Georgia,"Times New Roman",serif;"><br />
</span></b><br />
<b><span style="font-family: Georgia,"Times New Roman",serif;">9.Find all the students whose marks is greater than the average marks.</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Student(Name,Marks)</span><b><span style="font-family: Georgia,"Times New Roman",serif;"></span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Select Name from Student having Marks>Avg(Marks) group by Name.</span><br />
<br />
<span style="font-family: Georgia,"Times New Roman",serif;"><b>10.Whats the diff bt group by and orderby ? </b></span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">Group by-This is used only with aggregate functions.It sorts by rows.The results are displayed in groups.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">orderby-mainly used with select statements.sorts by columns.</span><br />
<div style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b></div><span style="font-family: Georgia,"Times New Roman",serif;"><b>11.</b></span><b><span style="font-family: Georgia,"Times New Roman",serif;">What is a default TCP/IP socket assigned for SQL Server</span>?</b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">1433 </span><b></b><br />
<div style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b> </div><b style="font-family: Georgia,"Times New Roman",serif;"><span style="font-family: Georgia,"Times New Roman",serif;">12.Whats the output of the foll sql statement-</span>Student(Name,Roll no) contains 3 rows.Select 1,2,'India' from Student</b><b></b><br />
<b><br />
</b><br />
<div style="font-family: Georgia,"Times New Roman",serif;">It prints 3 columns and 3 rows . the first rows all the column contains 1. the second column contains 2 and 3rd contains india.</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><b>13.How do you delete repeated data by maintaining atleast on occurence of the data.</b></div><div style="font-family: Georgia,"Times New Roman",serif;">Student(Name,Roll no) <b><br />
</b></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;">a)if there are 2 repeated records it deletes the one one occurence.</div><div style="font-family: Georgia,"Times New Roman",serif;"></div><div style="font-family: Georgia,"Times New Roman",serif;">delete top(1) from student where name='Cha'</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;">b)select distinct * from student</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"></div><div style="font-family: Georgia,"Times New Roman",serif;">c)Rowcount can be set.the belwo queries deletes only one occurrence of repeated data.</div><div style="font-family: Georgia,"Times New Roman",serif;">set rowcount 1</div><span style="font-family: Georgia,"Times New Roman",serif;">delete from student where name='cha'</span><br />
<div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="color: red;"><u><b><span style="font-family: Georgia,"Times New Roman",serif;">Stored Procedure </span></b></u></div><b><span style="font-family: Georgia,"Times New Roman",serif;">1.What are Stored Procedure ?</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">They are set of SQL statements which have been grouped together and stored in database</span>.<br />
<div style="font-family: Georgia,"Times New Roman",serif;">They can be executed over and over again.</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><b>2.How to compile stored procedure on each execution?</b></div><div style="font-family: Georgia,"Times New Roman",serif;">By using recompile option.</div><div style="font-family: Georgia,"Times New Roman",serif;">exec sp_recompile MyStoredProcedure.<br />
<br />
<b>3.Write a SP using input parameters.</b><br />
create procedure sp <br />
@id int<br />
as<br />
select * from <tablename> where ID=@id<br />
<br />
exec sp 22 <br />
<br />
<b>4.Write a SP to using input and output parameters.</b> <br />
create procedure sp <br />
@id int,<br />
@Name varchar output<br />
as<br />
select Name from recent where ID=@id<br />
<br />
declare @Name varchar<br />
exec sp 22,@Name output<br />
<br />
You have to declare the output parameter before printing it.<br />
<br />
<b>5.Write a sp to update a column taking user inputs.</b></div><div style="font-family: Georgia,"Times New Roman",serif;">create procedure sp <br />
@Name varchar(20),<br />
@id int<br />
as<br />
update <tablename> set Name =@Name where ID=@id<br />
<br />
exec sp 'test' ,22<br />
<br />
<b>6. How Implement error handling in stored procedure ?</b><br />
<div style="font-family: Georgia,"Times New Roman",serif;">There are many diff ways-<br />
a)Try-Catch Block<br />
b)@@Errorcount<br />
<br />
<b>7.Whats the diff bt user defined function and stored procedure.</b><br />
A user-defined function is a routine that encapsulates useful logic for use in other queries <br />
a)UDF functions can be used with select statement.Sp cannot.<br />
b)SP can /cannot return more than one value.UDF has to return values and it can return only one value.<br />
c)SP can have both input and output parameters wheras UDF can have only input parameters.<br />
d)Sp can have try catch block to handle exceptions ,this cannot be done in UDF.<br />
e)UDF can be called from procedure whereas visa versa is not possible.<br />
<br />
</div></div><div style="color: red; font-family: Georgia,"Times New Roman",serif;"><u><b>Trigger </b></u></div><div style="font-family: Georgia,"Times New Roman",serif;"><b>1.What is Trigger ?</b></div><div style="font-family: Georgia,"Times New Roman",serif;">They are special kind of stored procedure that are automatically executed. They are executed when an insert,update or delete operation is performed.</div><div style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b>2.Can you fire Trigger from c#?</b></div><div style="font-family: Georgia,"Times New Roman",serif;">No</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><b></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b>3.can stored procedure fire Triggers?</b></div><div style="font-family: Georgia,"Times New Roman",serif;">Yes<b><br />
</b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b><br />
<div style="color: red;"><b><u>JOINS</u></b></div><b> </b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b> </b> Student Teacher <br />
<div class="separator" style="clear: both; text-align: center;"><b></b></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMq-wPHkjtzLQaVGnG0AVkCT5jcjaNqHlSE_rQu-deyfxpdTsyupvG6MqXzRd262ofNWscnmN0xkBot0uPaODs5-0Owaf65rb3lR40Keu15k8Gvk35q-P6GJV_itcWVGOXIyyiGQ6e-t0/s1600/1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMq-wPHkjtzLQaVGnG0AVkCT5jcjaNqHlSE_rQu-deyfxpdTsyupvG6MqXzRd262ofNWscnmN0xkBot0uPaODs5-0Owaf65rb3lR40Keu15k8Gvk35q-P6GJV_itcWVGOXIyyiGQ6e-t0/s320/1.jpg" /></a></div><a href="http://3.bp.blogspot.com/_PNI2NmTKsfQ/TISidEI0YzI/AAAAAAAAA74/EI0OOg-3gJI/s1600/1.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"></a><br />
<b> </b><br />
<b>1. What do you mean by cross join ?</b><br />
It joins both the tables and returns the Cartesian product of both of them <b>.</b><br />
<b><br />
</b><br />
<i>select * from Student,Teacher</i><b><br />
</b><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3hvNUkm5zyNvUNuZW_te0pW08Qj3TOSKD6dB6eHKW8ISjqfxiJJTZati6RKHy5xa1pnNmkMTJpkm5qg_Tqo71lyZHqAPLRCTeu7JVQynW7NtHE96pwVA6D_Zeqmj_p3q67CQ4k_Hqknc/s1600/1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3hvNUkm5zyNvUNuZW_te0pW08Qj3TOSKD6dB6eHKW8ISjqfxiJJTZati6RKHy5xa1pnNmkMTJpkm5qg_Tqo71lyZHqAPLRCTeu7JVQynW7NtHE96pwVA6D_Zeqmj_p3q67CQ4k_Hqknc/s320/1.jpg" /></a></div><b><br />
</b><br />
<b>2.What is inner join ?</b><br />
it joins two tables based on the atleast one match in both the tables.<br />
select * from Student s inner join teacher t on s.id=t.id<b><br />
</b><br />
<b><br />
</b><br />
<b>3.what is left outer join ?</b><br />
Prints all the values in the first table even if there are no matches in the second table .corresponding unmatched value in second table is printed as null<br />
<br />
<b>3.what is right outer join ?</b><b> </b><br />
Prints all the values in the second table. corresponding value in first table is printed as null<br />
<b><br />
</b></div><div style="font-family: Georgia,"Times New Roman",serif;"><div style="color: red;"><b><u>UNION</u></b></div><b>1.What is union?</b><br />
combines only distinct values from both the tables into a single table.<br />
<i>select * from Student<br />
union <br />
select * from Teacher</i> <br />
<br />
<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDkZsbCiwx_SeC-hdTmKmg3H1b34ZYmO4Kx6QUUY-R8RVlpXVwCcKTLc7N8HY8y_vQt8nAEPDINW-PpAS5RyM49RrrymNtX6LTEu8fIdOy36OQZqRiisqmJVTszek2XJV2W8oFefoxIDA/s1600/1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDkZsbCiwx_SeC-hdTmKmg3H1b34ZYmO4Kx6QUUY-R8RVlpXVwCcKTLc7N8HY8y_vQt8nAEPDINW-PpAS5RyM49RrrymNtX6LTEu8fIdOy36OQZqRiisqmJVTszek2XJV2W8oFefoxIDA/s320/1.jpg" /></a></div><br />
<i>select * from Teacher<br />
union <br />
select * from </i><i>Student</i><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE9Wp7SFXXUW9hRwi6dDT4Y6tPVC6Av1UCKM4nYvRu4X0zCntHTWW70XukM_NrdhW5hPl4_sFwFQwWPiNFagUHYXqdH8k0z01_YklDLl1gBW6r1tWthtKMtQEtgeTXwUtYUryc5SMVRNM/s1600/1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE9Wp7SFXXUW9hRwi6dDT4Y6tPVC6Av1UCKM4nYvRu4X0zCntHTWW70XukM_NrdhW5hPl4_sFwFQwWPiNFagUHYXqdH8k0z01_YklDLl1gBW6r1tWthtKMtQEtgeTXwUtYUryc5SMVRNM/s320/1.jpg" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"></div><i> </i><br />
<b>2.What is union all ?</b><br />
Combines all the values from both the tables.<br />
<br />
<br />
<i>select * from Teacher<br />
union all<br />
select * from </i><i>Student</i><br />
<br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyH72y49nYAOE211dARYpJJYEunIfuNMDYgIvoKBBUx2b-uMV216c-GsUcPdxKe7q5mH_A8yN_Thic_cH0_hqg3Jwlh1VVVzNuo3Gct9_O_a1DLNB78bv0942ZDACFmVpdTwVwGeKwNtA/s1600/1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyH72y49nYAOE211dARYpJJYEunIfuNMDYgIvoKBBUx2b-uMV216c-GsUcPdxKe7q5mH_A8yN_Thic_cH0_hqg3Jwlh1VVVzNuo3Gct9_O_a1DLNB78bv0942ZDACFmVpdTwVwGeKwNtA/s320/1.jpg" /><span id="goog_1231948463"></span><span id="goog_1231948464"></span></a></div><b>View</b><br />
<b>1.What is View?</b><br />
It is a virtual table which encapsulated many complex queries.<br />
<br />
<b>2.Advantages and disadvantage of using a view? </b><br />
a)A temp table can be created by joining many tables.<br />
b)selective exposure of data from the original table. <br />
c)restrict the access to the original table. <br />
d)They do not consume space as they are created dynamically.<br />
<i>disadvantage</i><br />
a)When table is dropped view becomes inactive<br />
b)cannot use DML if view is created using more than one table<br />
<br />
<b>3.How do you create a View?</b><br />
Create View<Viewname> as<br />
select * from <tablename><br />
<br />
<b>4. If data is changed in actual table is it reflected in view ?</b><br />
Yes<br />
<br />
<b>5.If data is changed in View is it reflected in </b><b>actual table</b><b>?</b><br />
No <b><br />
</b><br />
<br />
<u><b>Index</b></u><br />
<b>1.What are Indexes ?</b><br />
Indexes is similar to indexes in dictionary.it helps in finding the data quickly.Therefore indexes are created on columns which are accessed frequently, so that the information can be retrieved quickly. Indexes can be created on a single column or a group of columns. When a index is created, it first sorts the data and then it assigns a ROWID for each row.<br />
<br />
<b>2.How do you create Indexes ?</b><br />
Create index A on Student (Name,Age) <b></b><br />
<b><br />
</b><br />
<b>3.What are diff types of index in SQL?</b><br />
Clustered index- Reorders the records in the way they are created in the table.The logical grouping of table is similar to physical grouping.A table can have only one clustered index.<br />
<div style="font-family: Georgia,"Times New Roman",serif;">Non clustered index-<span style="font-size: small;">he logical order of the index does not match the physical stored order of the rows on disk.</span>A table can have more than one clustered index.</div><br />
Note--i personally found this website really good for sql -http://www.w3schools.com<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>Unknownnoreply@blogger.com8tag:blogger.com,1999:blog-3329736017315021535.post-23054444062340976742010-08-29T20:39:00.000-07:002010-12-22T19:40:11.419-08:00WCF<div style="font-family: Verdana,sans-serif;"><b>1.What is WCF ?</b></div><div style="font-family: Verdana,sans-serif; text-align: left;">Windows Communication Foundation is a framework for building Service<br />
Oriented Application(SOA).It was introduced in .Net Framework 3.0 and is<br />
basically a combined feature of WebService,Remoting,MSMQ and COM+.</div><div style="font-family: Verdana,sans-serif;"><br />
</div><div style="font-family: Verdana,sans-serif;"><b>2. Difference between Webservice and WCF ?</b></div><div style="font-family: Verdana,sans-serif; text-align: justify;">->WebService cab be hosted only in IIS </div><div style="font-family: Verdana,sans-serif; text-align: justify;">WCF can be hosted in IIS,windows Service,Self hosting and windows<br />
activation service.</div><div style="font-family: Verdana,sans-serif; text-align: justify;">->WebService can be accessed only through http protocol. WCF cab be accessed through http,tcp,MSMQ and named pipes.</div><div style="font-family: Verdana,sans-serif; text-align: justify;">->WebService works in stateless env. WCF can maintain states and sessions<b>.</b></div><div style="font-family: Verdana,sans-serif; text-align: justify;">->Webservice uses System.Xml.serialization name space for serialization. WCF uses System.Runtime.Serialization namespace for serialization </div><div style="font-family: Verdana,sans-serif;"><br />
</div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><b>3.What is .svc file?</b> </span><br />
<div style="text-align: justify;"><span style="font-size: small;">Its the file where service is defined and it will be the point of contact from </span></div></div><div style="font-family: Verdana,sans-serif; text-align: justify;"><span style="font-size: small;">the consumers.It contains name of service and code behind file name.It is used to know about the service.</span></div><div style="font-family: Verdana,sans-serif;"><br />
</div><div style="font-family: Verdana,sans-serif;"><b><span style="font-size: small;">4.What are different ways in which WCF can be hosted ?</span></b></div><div style="font-family: Verdana,sans-serif;"><span style="font-size: small;">The different hosting techniques are</span><br />
<span style="font-size: small;">1.<u>IIS hosting</u>--This is the most commonly used hosting technique.Here IIS is</span><br />
<span style="font-size: small;"> used as a </span><span style="font-size: small;">server and has following </span><br />
<span style="font-size: small;">advantages -> starts automatically on the first client request,process recyling.</span></div><div style="font-family: Verdana,sans-serif;"><div style="text-align: left;"><span style="font-size: small;">Disadvantage-- It supports only http protocol</span><br />
<br />
<span style="font-size: small;">2.<u>Self hosting</u>-This is hosting the WCF urself either in console/windows </span><br />
<span style="font-size: small;">application </span><span style="font-size: small;">also in windows service</span><span style="font-size: small;"> .</span></div><ul><li><span style="font-size: small;">The host process should be running before a client makes a call to servc.</span></li>
<li><span style="font-size: small;"> Its easier to debug and deploy.</span></li>
<li><span style="font-size: small;"> Lifetime of services can be controlled using Open and Close methods.</span></li>
</ul><span style="font-size: small;">3. <u>WAS hosting</u>(Windows Activation Server hosting)--WAS was introduced</span><br />
<span style="font-size: small;">with windows </span><span style="font-size: small;">vista and it is shipped with IIS 7.0. it is more powerful than</span><br />
<span style="font-size: small;"> IIS 6.0 as it can support </span><span style="font-size: small;">http,tcp and named pipes whereas IIS 6.0 can </span><br />
<span style="font-size: small;">support only http.</span><span style="font-size: small;"> </span><br />
<br />
<span style="font-size: small;">4.<u>Windows Service Hosting</u>--Here the service can be programmed to start </span><br />
<span style="font-size: small;">when the </span><span style="font-size: small;">system starts.</span><br />
<br />
<b><span style="font-size: small;">5.What do you mean by ABC in WCF ?</span></b><span style="font-size: small;"> </span><br />
<span style="font-size: small;">ABC in WCF means -</span><br />
<span style="font-size: small;"><u>Address </u>-> A stands for Address. It indicates where you service is located.A URL is used to point to the location.Depending on whethere the service is hosted in http,tcp... the address varies. eg-</span><br />
<span style="font-size: small;"> http://localhost/Test</span><br />
<span style="font-size: small;">net.tcp//localhost/Test</span><br />
<br />
<span style="font-size: small;"><u>Binding </u>->B stands for Binding which specifies how the client should communicate with the service.</span><br />
<br />
<span style="font-size: small;"><u>Contract</u>->C stands for contracts. It exposes the operation provided by the Service. It is a contract.</span><span style="font-size: small;"> </span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"><b>6.What is an endpoint in WCF ?</b> </span><br />
<span style="font-size: small;">ABC together constitute an endpoint.Endpoint provides the client access to the functionality exposed by the service.</span><br />
<span style="font-size: small;"> </span><br />
<b><span style="font-size: small;">7.What do you mean by contarcts. What are the different types of contracts ? </span></b><br />
<span style="font-size: small;">Contracts are </span><span style="font-size: small;">standard way of describing the operations performed by a Service.Diff types of contracts are--</span><br />
<br />
<span style="font-size: small;"> </span><br />
<span style="font-size: small;">1.<u>Service Contracts</u> </span><br />
<span style="font-size: small;">It describes the operations provided by the service.</span><b><span style="font-size: small;">WCF service </span></b><br />
<span style="font-size: small;">should have atleast one ServiceContract.</span><b><span style="font-size: small;">it has two attribute-</span></b><br />
<span style="font-size: small;">[ServiceContract] --Used to define the interface.Client can talk to services via interfaces.</span><br />
<span style="font-size: small;">Similar to [Webservice] attribute in Webservic</span><span style="font-size: small;">e</span> <br />
<span style="font-size: small;">[OperationContract]-Used to define methods inside the interface.Similar to</span><span style="font-size: small;"> </span><br />
<span style="font-size: small;">[WebMethods]</span><b><span style="font-size: small;"> </span></b><br />
<b><span style="font-size: small;"> eg- </span></b><link href="file:///C:%5CUsers%5CNAVEEN%7E1%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml" rel="File-List"></link><link href="file:///C:%5CUsers%5CNAVEEN%7E1%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx" rel="themeData"></link><link href="file:///C:%5CUsers%5CNAVEEN%7E1%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml" rel="colorSchemeMapping"></link> <m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent><style>
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;
mso-font-charset:0;
mso-generic-font-family:roman;
mso-font-pitch:variable;
mso-font-signature:-1610611985 1107304683 0 0 159 0;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:-1610611985 1073750139 0 0 159 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-parent:"";
margin-top:0in;
margin-right:0in;
margin-bottom:10.0pt;
margin-left:0in;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
.MsoChpDefault
{mso-style-type:export-only;
mso-default-props:yes;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
.MsoPapDefault
{mso-style-type:export-only;
margin-bottom:10.0pt;
line-height:115%;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style> </m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"> <span style="font-family: Verdana,sans-serif;"> [ServiceContract()]</span><o:p style="font-family: Verdana,sans-serif;"></o:p></span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"> public interface ISimpleCalculator<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><span style="font-family: Verdana,sans-serif;"> { </span><o:p style="font-family: Verdana,sans-serif;"></o:p></span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"> [OperationContract()]<o:p></o:p></span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"> int Add(int a, int b);</span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><o:p> }</o:p></span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><o:p>2. <u>DataContract</u></o:p></span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: small;"><o:p> </o:p></span><span style="font-size: 10pt;"><span style="font-size: small;">This defines the data which is exchanged between the client and the service.</span></span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: 10pt;"><span style="font-size: small;"> these are used manily for used defined objects.They are of two types</span></span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: 10pt;"><span style="font-size: small;"> [DataContract]--defines the class</span></span></div><div class="MsoNormal" style="font-family: Verdana,sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="font-size: 10pt;"><span style="font-size: small;"> [DataMember] --defines the properties.</span></span></div><span style="font-size: small;">eg</span>- <br />
<pre style="font-family: Verdana,sans-serif;"><span style="font-size: small;">[DataContract]</span></pre><pre style="font-family: Verdana,sans-serif;"><span style="font-size: small;"> class Name
{</span></pre><pre style="font-family: Verdana,sans-serif;"><span style="font-size: small;"> public string Fullname; </span></pre><pre style="font-family: Verdana,sans-serif;"><span style="font-size: small;"> [DataMember]
public string FirstName;
[DataMember]
public string SurName;
}</span></pre><br />
<pre style="font-family: Verdana,sans-serif;"><span style="font-size: small;">Inbuilt types like string (Fullname) are defined impicitly and they do not need</span></pre><pre style="font-family: Verdana,sans-serif;"><span style="font-size: small;">data </span><span style="font-size: small;">contracts</span><span style="font-size: small;">.</span></pre><pre><span style="font-size: small;"> </span></pre><pre style="font-family: Verdana,sans-serif;"><span style="font-size: small;">3.Fault Contracts. </span></pre>These are used to handle errors in a service.When a service throws an error it<br />
does not reach the client side. But by using fault contract we can come to know the<br />
error that is raised by the service.<br />
eg-<br />
<pre class="csharp" style="font-family: Verdana,sans-serif;"><span style="font-size: small;">[ServiceContract()]
public interface ISimpleCalculator
{
[OperationContract()]
[FaultContract(typeof(ArgumentException))]
int Add(int a, int b);
}</span></pre><pre class="csharp" style="font-family: Verdana,sans-serif;"></pre><pre class="csharp" style="font-family: Verdana,sans-serif;">Raise the exception as</pre><pre class="csharp" style="font-family: Verdana,sans-serif;">throw new FaultException<customexception>("error") ;</customexception></pre><br />
4.<i>Message Contracts</i><br />
Message Contract defines the way messages are transferred using SOAP messages. It<br />
is used if you want to customize the SOAP format.<br />
eg-<br />
<pre class="csharp" style="font-family: Verdana,sans-serif;">[MessageContract]
public class CustomerDetails
{
[MessageHeader]
public string CustID;
[MessageBodyMember]
public string Name;</pre><pre class="csharp" style="font-family: Verdana,sans-serif;">}</pre><br />
<b>8.Whats the diff between Message Contract and Data Contract.</b><br />
Data contracts are used to describe data types used by service.They can be either parameter or return type.<br />
Message Contract are used to describe SOAP message format.They allow us to cotnrol the detail is SOAP header and body.<br />
<br />
<b>9.What namespace is used to access WCF ?</b><br />
<span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;">System.ServiceModel</span></span><br />
<br />
<b><span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;">10.What are the main components of WCF?</span></span></b><br />
<span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;">1.Service Class--functional class using any .net language.</span></span><br />
<span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;">2.Hosting environment--IIS,windows service etc</span></span><br />
<span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;">3.Endpoint--ABC</span></span><br />
<br />
<b><span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;">11.what is proxy in WCF?</span></span></b><span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;"> </span></span><br />
A proxy is a class by which a service client can Interact with the service.By the use of proxy in the client application we can call different methods in the service.<span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;"></span></span><br />
<span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;"><br />
</span></span><br />
<span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;"><b>12.What are two method in which you can access WCF?</b></span></span><br />
<span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;">By Adding it as reference -- this will automatically generate the channel required for you to communicate with WCF.</span></span><br />
<span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;">By creating channel manullay- use </span></span><span style="color: black;">ChannelFactory.</span><br />
<span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;">however the second method should be preferred one as pointed out in below article</span></span><br />
<span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;"><a href="http://www.eggheadcafe.com/tutorials/aspnet/a1647f10-9aa4-4b0c-bbd9-dfa51a9fab8e/adding-wcf-service-refere.aspx">http://www.eggheadcafe.com/tutorials/aspnet/a1647f10-9aa4-4b0c-bbd9-dfa51a9fab8e/adding-wcf-service-refere.aspx</a><br />
</span></span></div><div style="font-family: Verdana,sans-serif;"><span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;"><br />
</span></span><br />
<div><b><span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;">13.How do you achieve method overloading in WCF?</span></span></b></div><div><span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;">By making use of name property in OperationContract</span></span></div><div><b><span style="font-weight: normal;">[ServiceContract]</span><br style="font-weight: normal;" /><span style="font-weight: normal;">interface ISimpleCalculator</span><br style="font-weight: normal;" /><span style="font-weight: normal;">{</span><br style="font-weight: normal;" /><span style="font-weight: normal;"> [OperationContract(Name="Add2numbers")]</span><br style="font-weight: normal;" /><span style="font-weight: normal;"> int Add(int a,int b)</span><br style="font-weight: normal;" /><br style="font-weight: normal;" /><span style="font-weight: normal;"> [OperationContract(Name="AddDouble")]</span><br style="font-weight: normal;" /><span style="font-weight: normal;"> int Add(double a,double b)</span><br style="font-weight: normal;" /><span style="font-weight: normal;">}</span></b></div></div><div style="font-family: Verdana,sans-serif;"></div><div style="font-family: Verdana,sans-serif;"><span style="font-weight: normal;"><b>14.Why normal method overloading is not possible in WCF ?</b></span></div><div style="font-family: Verdana,sans-serif;"><b><span style="font-weight: normal;">Because WSDL is not a OO language and it does not support OOPs concept.</span></b><br />
<br />
<span style="font-weight: normal;"><b>15</b>. <b>How do you host a webservice in windows service?</b></span><br />
<br />
<b><span style="font-weight: normal;"><a href="http://msdn.microsoft.com/en-us/library/ms733069.aspx">http://msdn.microsoft.com/en-us/library/ms733069.aspx</a></span></b><br />
<br />
<span style="font-weight: normal;">1</span><span style="font-weight: normal;"><b>6</b>.</span><span style="font-weight: normal;"><b>simple eg for using channel factory</b>.</span><br />
<b><span style="font-weight: normal;"> </span></b><br />
<b><span style="font-weight: normal;"><a href="http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication">http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication</a></span></b></div><div style="font-family: Verdana,sans-serif;"><br />
<div style="padding-left: 30px;"></div><div style="padding-left: 30px;"></div> <br />
<b><span style="font-size: small;"> </span></b> </div>Unknownnoreply@blogger.com12tag:blogger.com,1999:blog-3329736017315021535.post-28304410323793143332010-08-29T18:57:00.000-07:002011-01-05T23:51:09.601-08:00Collection<div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b>1.What is an Array ? What are different ways of writing an Array ?</b></span><br />
<span style="font-size: small;">Array is a datastructure that stores a collection of value that are of same data type.</span><br />
<span style="font-size: small;">diff ways of writing an array are-</span><br />
<span style="font-size: small;">a)specify the data length in declaration.</span><br />
<span style="font-size: small;">int [] count= new int[5];</span><br />
<br />
<span style="font-size: small;">b) int[] count = new int[] { 1, 2, 3 };</span><br />
<span style="font-size: small;">skip the length but have to specify the value.</span><br />
<br />
<span style="font-size: small;">c)</span><span style="font-size: small;">int[] count = new int[2] { 1, 2, 3 };</span><br />
<span style="font-size: small;">both a and b. one thing should be taken care here the length of int array should be equal</span><br />
<span style="font-size: small;">to number of values specified.</span><br />
<span style="font-size: small;"><b></b></span><br />
<span style="font-size: small;"><b><br />
</b></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b>2.Array is reference type or value type ?</b></span><br />
<span style="font-size: small;">Reference Type </span><br />
<span style="font-size: small;"><b><br />
</b></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b>3.How do you search an item in an Array ?</b></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">The BinarySearch static method of Array class can be used to search for an item in a array. . The method takes at least two parameters - an array and an object (the item you are looking for). If an item found in an array, the method returns the index of the item (based on first item as 0<sup>th</sup> item), else method returns a negative value. </span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">eg- <br />
<span style="color: black;">string[] name = new string[] { "chai", "alex", "dave" }; </span></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><span style="color: black;">int i=Array.BinarySearch(name, "dfsdf"); </span></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><span style="font-size: x-small;"><span style="color: black; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: small;">i returns a negative value. </span><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;"></span></span></span><br />
<span style="font-size: x-small;"><span style="font-family: Verdana,Arial,Helvetica,sans-serif;"><span style="font-size: x-small;"> </span></span></span> <br />
<div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">4.How to achieve Deep copy and Shallow copy using Array ?</span></b><br />
<span style="font-size: small;">Deep Copy-- </span><span style="font-size: small;">By using Array.CopyTo</span><br />
<span style="font-size: small;">Shallow Copy---Array.Clone()</span><b><span style="font-size: small;"></span></b><br />
<b><span style="font-size: small;"><br />
</span></b><br />
<b><span style="font-size: small;"> </span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">5.What are different types of an Array ?</span></b><br />
<span style="font-size: small;">a) Single dimensional Array</span><br />
<span style="font-size: small;">b) Multidimensional Array</span><br />
<span style="font-size: small;">c) Jaggd Array</span><b><span style="font-size: small;"><br />
</span></b><br />
<br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">6.Can diff data types be stored in a single Array?</span></b><br />
<span style="font-size: small;">No</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">7.Where does array index starts ?</span></b><br />
<span style="font-size: small;">Array index starts at Zero.</span><br />
<span style="font-size: small;">Suppose you have int [] count= {1,2,3} then</span><br />
<span style="font-size: small;">int[0] will give you "1".</span><b><span style="font-size: small;"></span></b><br />
<b><span style="font-size: small;"><br />
</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">8.Give an example of accessing Array using foreach loop.</span></b><br />
<b><span style="font-size: small;"> </span></b><span style="font-size: small;">string[] name = new string[] { "chai", "alex", "dave" }; <br />
foreach (string a in name)</span><br />
<span style="font-size: small;"> {<br />
<b> </b></span><span style="font-size: small;"> Console.WriteLine(a.ToString()); </span><br />
<span style="font-size: small;">} </span><b><span style="font-size: small;"></span></b><br />
<b><span style="font-size: small;"><br />
</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">9. How do you sort an item in Array in reverse order ?</span></b><br />
<span style="font-size: small;">Use Count and Reverse property of an array.</span><br />
<span style="font-size: small;">eg-</span><br />
<span style="font-size: small;">int[] count = new int[] { 1, 2, 3,6,8,4 };<br />
Array.Sort(count);<br />
Array.Reverse(count);</span><br />
<br />
<b><span style="font-size: small;">10.Find the maximum no in an array.</span></b><br />
<span style="font-size: small;">you can use the property of array called Max or use the below algo-</span><br />
<br />
<br />
<div style="font-family: Verdana,sans-serif;"><span style="font-size: small;"><b>11.Convert arraylist to string array </b></span></div><div style="font-family: Verdana,sans-serif;"><!--[if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:RelyOnVML/> <o:AllowPNG/> </o:OfficeDocumentSettings> </xml><![endif]--><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>EN-SG</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:DontVertAlignCellWithSp/> <w:DontBreakConstrainedForcedTables/> <w:DontVertAlignInTxbx/> <w:Word11KerningPairs/> <w:CachedColBalance/> <w:UseFELayout/> </w:Compatibility> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="--> <m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent><!--[endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/> <w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/> <w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/> <w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/> <w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/> <w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/> <w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/> <w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/> <w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/> <w:LsdException Locked="false" Priority="37" Name="Bibliography"/> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
</style> <![endif]--> </m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac></div>Suppose you have a arraylist say with 3 string values- a[0]-name,a[1]-age,a[2]-gender.After converting using below code it will look like <br />
<br />
string.Join(",",(string[])a.ToArray(typeof(string)))<br />
<br />
string a=name,age,gender<br />
<br />
<span style="font-size: small;"><b> </b></span><br />
<br />
<br />
<b><span style="font-size: small;"> </span></b><br />
<span style="font-size: small;"><br />
</span></div>Unknownnoreply@blogger.com23tag:blogger.com,1999:blog-3329736017315021535.post-19414451511828407412010-08-28T21:03:00.001-07:002010-09-22T20:49:16.333-07:00.Net Framework<div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b>1.What is Framework ?</b></span><br />
<span style="font-size: small;">Framework is special kind of libraries or structures that helps in building applications. </span><br />
<br />
<b><span style="font-size: small;">2.What is .Net Framework ?</span></b><br />
<span style="font-size: small;">It is collection of libraries and API designed by microsoft which helps in building,deploying and running applications and services that use >net technologies.</span><b><span style="font-size: small;"> </span></b><br />
<span style="font-size: small;">In simple words a .net framwork is a combination of several diff technology like CLR,asp.net,garbage collection etc that helps in easing the process of software development.</span><b><span style="font-size: small;"></span></b><br />
<b><span style="font-size: small;"><br />
</span></b><br />
<b><span style="font-size: small;">3.What are the features of .Net framework ?</span></b><br />
<span style="font-size: small;">MSIL,CLR,CTS,Assemblies </span><b><span style="font-size: small;"><br />
</span></b><br />
<b><span style="font-size: small;"><br />
</span></b><br />
<b><span style="font-size: small;">4.Briefly explain how the code is compiled by the framework ?</span></b><br />
<span style="font-size: small;">The .net code first is compiled into MSIL/IL i.e intermediate language </span><span style="font-size: small;">which is machine independant. At this stage metadata is generated which contains the member signature.This code then gets compiled into machine specific language known as native language</span><b><span style="font-size: small;"> </span></b><span style="font-size: small;">by JIT(just in time ) compiler.</span><b><span style="font-size: small;"></span></b><br />
<b><span style="font-size: small;"><br />
</span></b><br />
<b><span style="font-size: small;">5.What is JIT ?</span></b><br />
<span style="font-size: small;">Just -In-Time compiler compiles the IL code to native code so that the machine can understand that language.JIT runs on demand when a method is called JIT analysis the IL and produces highly efficient code. So if the next time same piece of code i execitued then it runs and not compiled.</span><span style="font-size: small;">JIT is specific to OS</span><b><span style="font-size: small;">.</span></b><br />
<b><span style="font-size: small;"><br />
</span></b><br />
<b><span style="font-size: small;">6.What is AOT ?</span></b><br />
<span style="font-size: small;">Ahead-Of-Time compilation.the JIT runs just before the code execution hence it does not have enough time of optimize the code. hence cam AOT.It compiles the entire .net assembly into IL during application installation.</span><b><span style="font-size: small;"></span></b><br />
<span style="font-size: small;">ngen is a type of AOT</span><b><span style="font-size: small;"><br />
</span></b><br />
<b><span style="font-size: small;"><br />
</span></b><br />
<b><span style="font-size: small;">7.What is ngen.exe ?</span></b><span style="font-size: small;"><b><span style="font-family: Georgia,"Times New Roman",serif;"></span></b></span><br />
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;">Native Image Generator.It compiles the entire assembly during installation.</span><br style="font-family: Georgia,"Times New Roman",serif;" /><span style="font-family: Georgia,"Times New Roman",serif;">It creates native images that are nothing but files so that the next time compiles compiles it picks up these images instead of files from JIT.</span></span><span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">This helps in faster compilation.It can be used only if ngen is used for all the assembly in the applicatio</span>n.</span></span><b><span style="font-size: small;"></span></b><br />
<b><span style="font-size: small;"><br />
</span></b><br />
<b><span style="font-size: small;">8.How MSIL helps in language interopability ?</span></b><br />
<span style="font-size: small;">MSIL </span><span style="font-size: small;">is machine independant language.</span><span style="font-size: small;">no matter which language you use in .net all of then are converted into MSIL .thus </span><span style="font-size: small;">helping diff language coexist with each other.</span><br />
<span style="font-size: small;"><br />
</span><br />
<b><span style="font-size: small;">9.What is CLR?</span></b><br />
<span style="font-size: small;">Common language runtime.it is the heart of .net framework and it takes care of code execution.It helps in running your program by acting as a translator between your program and the computer you are running it on.features of CLR -</span><br />
<span style="font-size: small;">a)<i>Garbage Collection</i>-helps in automatic memory management by disposing or the objects when they are not being referenced anymore. </span><br />
<span style="font-size: small;">b)<i>IL to native code</i> -CLR uses JIT compiler to convert MSIL to native code.</span><br />
<span style="font-size: small;">c)Code access security(CAS)-provides right to certain programs. eg if a piece of code is trying to delete a file for which it does not have permission, CLR prevents it from doing so.</span><br />
<span style="font-size: small;">d)Code verification-ensures type safety and prevents code from accessing invalid memory locations etc.</span><br />
<span style="font-size: small;"><br />
</span><br />
<b><span style="font-size: small;">10.What is CTS ?</span></b><br />
<span style="font-size: small;">Common type system ,defines set of data types that are common for all the languages in .net.eg-long in vb.net and int in c# both point to system.int32 in IL.</span><br />
<span style="font-size: small;"> </span><br />
<b><span style="font-size: small;">11.What is CLS ?</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Common language specification</span><b><span style="font-size: small;">,</span></b><span style="font-size: small;">defines rules that all the languages must follow in order to co-exist among each other.</span></div><br />
<div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">8.What are languages supported in .Net ?</span></b><br />
<span style="font-size: small;">it supports over 60 languages some of them are-c#,ada,C++, j#,Perl,VB,cobol etc. </span><b><span style="font-size: small;"><br />
</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;"><br />
</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">9.What is .Vshost ?</span></b></div><span style="font-family: Georgia,"Times New Roman",serif;">when we build our vs project this exe is created in the bin folder.it is a hosting process.and is used only by visual studio.it helps in imporving performance and supports immediate window.</span><br />
<br />
<b><span style="font-family: Georgia,"Times New Roman",serif;">10.</span><span style="font-family: Georgia,"Times New Roman",serif;">what is managed and unmanaged code ?</span></b><br />
<span style="font-family: Georgia,"Times New Roman",serif;">the code which runs under CLR is called managed code eg-VB,C#.</span><br />
<span style="font-family: Georgia,"Times New Roman",serif;">the code which is not compiled by CLR is called unmanaged code.eg-C++</span><br />
<br />
<br />
<span style="font-family: Georgia,"Times New Roman",serif; font-size: small;"><span style="color: red;">Note:Also read About Assemblies </span></span><b><span style="font-family: Georgia,"Times New Roman",serif; font-size: small;"><br />
</span></b>Unknownnoreply@blogger.com9tag:blogger.com,1999:blog-3329736017315021535.post-58043282618084295572010-08-28T20:05:00.001-07:002010-09-23T01:28:44.458-07:00Assembly<div style="font-family: Georgia,"Times New Roman",serif;"><div style="font-family: Georgia,"Times New Roman",serif;"><b>1.What is an assembly ?</b></div><div style="font-family: Georgia,"Times New Roman",serif;"><div style="font-family: Georgia,"Times New Roman",serif;">it is unit of deployment.It is a file generated on successful compilation of .Net application. it can be either a DLL or an EXE.</div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><b>2.what are the features of Assembly?</b></div><div style="font-family: Georgia,"Times New Roman",serif;">a) They are self descrining. They consists of metadata which tells what are the methods,propeties etc present in the assembly.</div><div style="font-family: Georgia,"Times New Roman",serif;">b)Assembly can be loaded side-by side thus achieveing side by side execution.</div><div style="font-family: Georgia,"Times New Roman",serif;">c)installation of an assembly is easier.</div><div style="font-family: Georgia,"Times New Roman",serif;">d)Assemblies solve the DLL HELL problem.<b><br />
</b></div></div><br />
<div><div style="font-family: Georgia,"Times New Roman",serif;"><b>2.Whats the diff bt a DLL and and EXE </b></div><b><span style="font-family: "Georgia","serif";"> </span></b><span style="font-family: "Georgia","serif";"> <o:p></o:p></span><br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: medium none;"><tbody>
<tr style="height: 15.85pt;"> <td style="border: 1pt solid black; height: 15.85pt; padding: 0in 5.4pt; width: 167.25pt;" valign="top" width="223"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><b>DLL<o:p></o:p></b></div></td> <td style="border-color: black black black -moz-use-text-color; border-style: solid solid solid none; border-width: 1pt 1pt 1pt medium; height: 15.85pt; padding: 0in 5.4pt; width: 167.25pt;" valign="top" width="223"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><b>EXE<o:p></o:p></b></div></td> </tr>
<tr style="height: 16.75pt;"> <td style="border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; height: 16.75pt; padding: 0in 5.4pt; width: 167.25pt;" valign="top" width="223"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">Dynamic Link Library with .dll extension</div></td> <td style="border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 16.75pt; padding: 0in 5.4pt; width: 167.25pt;" valign="top" width="223"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">Executable with .exe extension</div></td> </tr>
<tr style="height: 16.75pt;"> <td style="border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; height: 16.75pt; padding: 0in 5.4pt; width: 167.25pt;" valign="top" width="223"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">Can have many entry points</div></td> <td style="border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 16.75pt; padding: 0in 5.4pt; width: 167.25pt;" valign="top" width="223"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">Has only one entry point</div></td> </tr>
<tr style="height: 16.75pt;"> <td style="border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; height: 16.75pt; padding: 0in 5.4pt; width: 167.25pt;" valign="top" width="223"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">Does not contain UI</div></td> <td style="border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 16.75pt; padding: 0in 5.4pt; width: 167.25pt;" valign="top" width="223"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">Contains UI</div></td> </tr>
<tr style="height: 16.75pt;"> <td style="border-color: -moz-use-text-color black black; border-style: none solid solid; border-width: medium 1pt 1pt; height: 16.75pt; padding: 0in 5.4pt; width: 167.25pt;" valign="top" width="223"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">It is an in-process file.that means it runsin someone else’s memory</div></td> <td style="border-color: -moz-use-text-color black black -moz-use-text-color; border-style: none solid solid none; border-width: medium 1pt 1pt medium; height: 16.75pt; padding: 0in 5.4pt; width: 167.25pt;" valign="top" width="223"><div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">It is out-process file.It can run independently. Its standalone.</div></td> </tr>
</tbody></table><br />
</div><meta content="text/html; charset=utf-8" http-equiv="Content-Type"></meta><meta content="Word.Document" name="ProgId"></meta><meta content="Microsoft Word 12" name="Generator"></meta><meta content="Microsoft Word 12" name="Originator"></meta><link href="file:///C:%5CUsers%5CNAVEEN%7E1%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml" rel="File-List"></link><link href="file:///C:%5CUsers%5CNAVEEN%7E1%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx" rel="themeData"></link><link href="file:///C:%5CUsers%5CNAVEEN%7E1%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml" rel="colorSchemeMapping"></link> <m:smallfrac m:val="off"> <m:dispdef> <m:lmargin m:val="0"> <m:rmargin m:val="0"> <m:defjc m:val="centerGroup"> <m:wrapindent m:val="1440"> <m:intlim m:val="subSup"> <m:narylim m:val="undOvr"> </m:narylim></m:intlim> </m:wrapindent><style>
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;
mso-font-charset:0;
mso-generic-font-family:roman;
mso-font-pitch:variable;
mso-font-signature:-1610611985 1107304683 0 0 159 0;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:-1610611985 1073750139 0 0 159 0;}
@font-face
{font-family:Georgia;
panose-1:2 4 5 2 5 4 5 2 3 3;
mso-font-charset:0;
mso-generic-font-family:roman;
mso-font-pitch:variable;
mso-font-signature:647 0 0 0 159 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-parent:"";
margin-top:0in;
margin-right:0in;
margin-bottom:10.0pt;
margin-left:0in;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman","serif";
mso-fareast-font-family:"Times New Roman";}
.MsoChpDefault
{mso-style-type:export-only;
mso-default-props:yes;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
.MsoPapDefault
{mso-style-type:export-only;
margin-bottom:10.0pt;
line-height:115%;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style> </m:defjc></m:rmargin></m:lmargin></m:dispdef></m:smallfrac><br />
<br />
<div style="font-family: Georgia,"Times New Roman",serif;"><b> </b></div></div><div style="font-family: Georgia,"Times New Roman",serif;"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b>2.What the physical location of assembly ?</b></span></div><div><span style="font-size: small;"> c:\Windows\assembly</span></div><div><br />
</div></div><div style="font-family: Georgia,"Times New Roman",serif;"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b>3.Different types of Assembly ?</b></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">a)Private Assembly</span></div><span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;">An assembly used by a single application is called private assembly. Its present in the bin folder.</span></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">b) SharedAssembly</span><br />
<div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">An assembly used by more than one application.Its present in GAC.</span></div><span style="font-size: small;"> </span></div><div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">c)Satellite Assembly</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">These are resource files which are compiled to assemblies. </span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">4.What is DLL Hell ?</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">DLL HELL is a problem which arises when a new version of application with a new set of DLL overrides the older version.The application which are using older version of DLL crashes because those have been replaced by new DLL which are not compatible with the old applicaitons.</span><b><span style="font-size: small;"></span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;"><br />
</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">5.How is DLL Hell solved in .Net?</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">It is solved with the help of Assemblies.Assemblies allow different versions of DLL to co-exist among themselves.This feature is called Versioning.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">6.What is Process ?</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Instance of computer program that is being executed.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;"><br />
</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">6.What are Application domains?</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">The domain in which your application runs. They provide isolation for running applications.</span><b><span style="font-size: small;"></span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">They are hosted inside Process.Single process can have more than one application domain. Communication between them can be achieved with the help of proxy. </span><b><span style="font-size: small;"></span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;"><br />
</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">7.How are </span></b><b><span style="font-size: small;">Application domains created in C#?</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;"><br />
</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">static void Main()<br />
{</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"> // Create an Application Domain:<br />
System.AppDomain newDomain = System.AppDomain.CreateDomain("NewAppDomain");<br />
<br />
// Load and execute an assembly:<br />
newDomain.ExecuteAssembly(@"d:\HelloWorld.exe");<br />
<br />
// Unload the application domain:<br />
System.AppDomain.Unload(newDomain);<br />
}</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">8.What is PE file ?</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Portable Executable File is either a DLL or an EXE.It is generated when a program is compiled.It consists of 3 part-</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">PE Header</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">MSIL</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Metadat</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;"><br />
</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">8.What are the contents of an Assembly ?</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">An assembly consists-</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">a)Manifest </span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">b)IL Code</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">c)Resource Files</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">d)Metadata</span><b><span style="font-size: small;"></span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;"><br />
</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">9.What is manifest ?</span></b></div><br />
<div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Manifest of an assembly contains the following-</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">a)Identity--consists of Assembly Name,Version No,Culture and Public Key Token.</span><b><span style="font-size: small;"></span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">b)List of File present in Assembly.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">c)A list of referenced assemblies.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">d)A set of permission requests.</span><b><span style="font-size: small;"></span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;"><br />
</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">10.What is metadata ?</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Contains all the</span><span style="font-size: small;"> type and member information present in the code</span><b><span style="font-size: small;">.</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;"><br />
</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">11.What is Single File and MultiFile assembly ?</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Single File Assembly-it consists of only one file.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Multifile Assembly-consists of more then one files like- module(.netmodule), resource file(x.jpg) etc.All of them can be linked to form one assembly.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">12.Whats the diff bt assembly and module ?</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Assembly contains the manifest info.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">modules does not have manifest info.They only contain metadata.They cannot be created in VS.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"> </span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b><br />
</b></span></div></div></div><div style="font-family: Georgia,"Times New Roman",serif;"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b>13.Can you compile an assembly with more than one file ?</b></span></div><div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Yes </span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b><br />
</b></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b>14.What is ILDASM ?</b></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Its a tool used to view contents of an assembly<b>. </b></span></div><span style="font-size: small;"><b><br />
</b></span><br />
<span style="font-size: small;"><b><span style="font-family: Georgia,"Times New Roman",serif;">15. what is ngen.exe ?</span></b></span><br />
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;">Native Image Generator.It compiles the entire assembly during installation.</span></span><br />
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;">It creates native images that are nothing but files so that the next time compiles compiles it picks up these images instead of files from JIT.</span></span><br />
<span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;">This helps in faster compilation.It can be used only if ngen is used for all the assembly in the application. </span><b><br />
</b></span><br />
<span style="font-size: small;"><b><br />
</b></span></div></div><div style="font-family: Georgia,"Times New Roman",serif;"><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">16.What is GAC ?</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">It a a cache for assemblies which are globally available. </span><span style="font-size: small;">For assemblies to be loadede in GAC they must have a strong name.</span><span style="font-size: small;">Strong name ensures that assemblies with same name exists in GAC.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b>17.How do install and uninstall assembly in GAC ?</b></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">install- gacutil -i <assembly name></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">uninstall-</span><span style="font-size: small;">gacutil -u <assembly name></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;"><b><span style="font-size: small;">18.What is strong name ?</span></b></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"> Its a .Net assembly name that consists of foll-</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">Name,Version,Culture Info and Public Key token.</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">It is used to help different versions of same assembly co-exist in GAC.</span></div><br />
<div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b>18.what is strong name key file?How is it created?</b></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">The snk.exe utility generated a public/private key pair that is stored in file called snk file(<name>.snk).it can be created by going to command prompt and typing-</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b> </b>snk -k <name>.snk</span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b><br />
</b></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b>19.What do you mean by signing a assembly</b></span></div><span style="font-size: small;"><span style="font-family: Georgia,"Times New Roman",serif;">it means ensuring your software does not fall into wrong hands. this is done by creating a .snk file for the assembly and then it is used to sign the assembly by giving it a strong name. </span><b><br />
</b></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">.Net uses digital signature to safe guard the integrity of an assembly .it follows</span><span style="font-size: small;"> Public-key cryptography.</span><br />
<br />
<b><span style="font-size: small;">20.Explain how public key cryptography works.</span></b><br />
<span style="font-size: small;">In this method both the sender and receiver will have set of keys know as public keys(which is used to encrypt a assembly) and private key(used to decrypt an assembly).when you sign an assembly using snk utility these two keys are embedded into the assembly. the assembly gets signed by the pubic key ,public key is freely distributed. the user who wants to use it must have the private key which is used to decrypt this assembly.</span><br />
<br />
<b>21.What is delay signing ?</b><span style="font-size: small;"> </span><br />
<span style="font-size: small;"><br />
</span></div></div></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b>22.What is satellite assembly ?</b></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">satellite assembly consists of resource files which for a specific language.it can be used for localization and globalization.</span><br />
<span style="font-size: small;"><b>read more about them here <a href="http://ads/">ads</a><br />
</b></span><br />
<span style="font-size: small;"><b><br />
</b></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b>23.what is shfusion.dll?</b></span><br />
<span style="font-size: small;">Its a dll that allows you to see the contents of GAC very easily.go to run command and type assembly ,it opens up a windows which shows the contents of assembly. <b><br />
</b></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;"><b><br />
</b></span></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b>16.How Windows diff win32 exe and managed exe ?</b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b><br />
</b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b>18. What is probing ?</b></div><div style="font-family: Georgia,"Times New Roman",serif;"><b>19.What is side by side execution ? </b></div><div style="font-family: Georgia,"Times New Roman",serif;"><br />
</div><div style="font-family: Georgia,"Times New Roman",serif;">20.How can you run assembly without .Net Framework ?</div><br />
<div style="font-family: Georgia,"Times New Roman",serif;">22.What is AL.exe and Resgen.exe</div><h4 style="font-family: Georgia,"Times New Roman",serif;"><br />
</h4><div style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: 9pt;"></span></div><h4 style="font-family: Georgia,"Times New Roman",serif;"><br />
</h4>Unknownnoreply@blogger.com10