<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Solomon &#187; Interview Questions &#8211; .NET</title>
	<atom:link href="http://www.ms.oyangudi.com/blog/category/interview-questions-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ms.oyangudi.com/blog</link>
	<description>from Oyangudi...</description>
	<lastBuildDate>Tue, 18 Oct 2011 02:38:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>.NET Interview Questions</title>
		<link>http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions/</link>
		<comments>http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 03:55:13 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[Interview Questions - .NET]]></category>
		<category><![CDATA[.NET Interview Questions]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=22</guid>
		<description><![CDATA[Collected from the Internet: 1. What is the difference between a Struct and a Class? Ans.Structs are value-type variables and are thus saved on the stack -&#62; additional overhead but faster retrieval. Another difference is that structs CANNOT inherit.&#160; Classes are reference types and structs are value types. Since classes are reference type, a class [...]]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text=".NET Interview Questions" data-url="http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<p><b>Collected from the Internet:</b>     <br /><b></b></p>
<p><b>1. What is the difference between a Struct and a Class?      <br />Ans.</b>Structs are value-type variables and are thus saved on the stack -&gt; additional overhead but faster retrieval. Another difference is that structs CANNOT inherit.&#160; Classes are reference types and structs are value types. Since classes are reference type, a class variable can be assigned null.But we cannot assign null to a struct variable, since structs are value type.     </p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #0000ff">struct</span> AStruct</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> {   </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span>   <span style="color: #0000ff">int</span> aField;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span> } </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span> <span style="color: #0000ff">class</span>  AClass</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span> {   </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span>    <span style="color: #0000ff">int</span> aField;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span> } </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   9:</span> <span style="color: #0000ff">class</span> MainClass</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  10:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  11:</span>    <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> Main() </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  12:</span>    {  </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  13:</span>        AClass b = <span style="color: #0000ff">null</span>;  <span style="color: #008000">// No error.</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  14:</span>        AStruct s = <span style="color: #0000ff">null</span>; <span style="color: #008000">// Error </span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  15:</span>        <span style="color: #008000">/* [ Cannot convert null to 'AStruct' because  it is a value type ].*/</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  16:</span>    }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  17:</span> } </pre>
</p></div>
</div>
<p>When you instantiate a class, it will be allocated on the heap.When you instantiate a struct, it gets created on the stack. You will always be dealing with reference to an object ( instance ) of a class. But you will not be dealing with references to an instance of a struct ( but dealing directly with them ).<br />
  <br />When passing a class to a method, it is passed by reference. When passing a struct to a method, it&#8217;s passed by value instead of as a reference. </p>
<p>You cannot have instance Field initializers in structs. But&#160; classes can have initializers. </p>
<p></p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #0000ff">class</span> MyClass</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> { </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span>   <span style="color: #0000ff">int</span> myVar =10;    <span style="color: #008000">//  no syntax error.    </span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span>   <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> MyFun( )    </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span>   {  </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span>      <span style="color: #008000">//  statements    </span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span>   }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span> } </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   9:</span> <span style="color: #0000ff">struct</span> MyStruct</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  10:</span> {    </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  11:</span>   <span style="color: #0000ff">int</span> myVar = 10;  <span style="color: #008000">//syntax error</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  12:</span>   <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> MyFun( )    </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  13:</span>   {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  14:</span>         <span style="color: #008000">//  statements    </span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  15:</span>   }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  16:</span> } </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  17:</span> Classes can have <span style="color: #0000ff">explicit</span> parameterless constructors. But structs cannot have <span style="color: #0000ff">explicit</span> parameterless constructors.</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  18:</span> <span style="color: #0000ff">class</span> MyClass</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  19:</span> {   </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  20:</span>   <span style="color: #0000ff">int</span> myVar = 10;   </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  21:</span>   <span style="color: #0000ff">public</span> MyClass( ) <span style="color: #008000">// no syntax error.  </span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  22:</span>   { </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  23:</span>      <span style="color: #008000">// statements   </span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  24:</span>   }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  25:</span> } </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  26:</span> <span style="color: #0000ff">struct</span> MyStruct</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  27:</span> {   </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  28:</span>   <span style="color: #0000ff">int</span> myVar;   </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  29:</span>   <span style="color: #0000ff">public</span> MyStruct( ) <span style="color: #008000">// syntax error.   </span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  30:</span>   { </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  31:</span>        <span style="color: #008000">// statements   </span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  32:</span>   }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  33:</span> } </pre>
</p></div>
</div>
<p>Classes must be instantiated using the new operator. But structs can be instantiated without using the new operator.<br />
  <br />MyClass aClassObj; </p>
<p>/*&#160; MyClass aClassObj=new MyClass(); is the correct </p>
<p>format.aClassObj.myVar=100;//NullReferenceException </p>
<p>(because aClassObj does not contain a reference to an object </p>
<p>of type myClass). */ </p>
<p>MyStruct&#160; aStructObj;aStructObj.myVar=100;// no exception. </p>
<p>Classes support inheritance.But there&#160; is no inheritance for structs. ( structs don&#8217;t support inheritance polymorphism ) </p>
<p><b>(1)</b> </p>
<p><b></b></p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #0000ff">struct</span> MyStruct</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span>  <span style="color: #0000ff">int</span> aStructVar; </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span>  <span style="color: #0000ff">internal</span> <span style="color: #0000ff">void</span> aStructMethod()</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span>  {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span>    <span style="color: #008000">// statements</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span>  }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span> }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   9:</span> <span style="color: #0000ff">class</span> MyClass : MyStruct   <span style="color: #008000">// Syntax error.</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  10:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  11:</span>   <span style="color: #0000ff">int</span> aClassVar; </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  12:</span>   <span style="color: #0000ff">int</span> aClassMethod() </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  13:</span>   {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  14:</span>      <span style="color: #008000">// statements</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  15:</span>   }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  16:</span> } </pre>
</p></div>
</div>
<p><b></p>
<p>
    <br />(2)</p>
<p></b></p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #0000ff">class</span> MyClass </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span>   <span style="color: #0000ff">int</span> aClassVar;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span>   <span style="color: #0000ff">int</span> aClassMethod()</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span>   {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span>      <span style="color: #008000">// statements</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span>   }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span> }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   9:</span> <span style="color: #0000ff">struct</span> MyStruct : MyClass   <span style="color: #008000">// Syntax error.</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  10:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  11:</span>   <span style="color: #0000ff">int</span> aStructVar;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  12:</span>   <span style="color: #0000ff">internal</span> <span style="color: #0000ff">void</span> aStructMethod()</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  13:</span>   { </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  14:</span>     <span style="color: #008000">// statements </span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  15:</span>   }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  16:</span> } </pre>
</p></div>
</div>
<p>Since struct does not support inheritance, access modifier of a member of a struct cannot be&#160; protected or protected internal. It is not mandatory to initialize all Fields inside the constructor of a class. But all the Fields of a struct&#160; must be fully initialized inside the constructor.<br />
  </p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #0000ff">class</span> MyClass <span style="color: #008000">//No error( No matter whether the Field </span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span>                    <span style="color: #008000">//'MyClass.myString' is initialized or not ).</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span> {   </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span>   <span style="color: #0000ff">int</span>  myInt;   </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span>   <span style="color: #0000ff">string</span> myString;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span>   <span style="color: #0000ff">public</span> MyClass( <span style="color: #0000ff">int</span> aInt ) </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span>   { </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span>      myInt = aInt;   </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   9:</span>   }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  10:</span> } </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  11:</span> <span style="color: #0000ff">struct</span> MyStruct <span style="color: #008000">// Error ( Field ' MyStruct.myString ' must </span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  12:</span>             <span style="color: #008000">//be fully assigned before it leaves the constructor ).</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  13:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  14:</span>    <span style="color: #0000ff">int</span> myInt;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  15:</span>    <span style="color: #0000ff">string</span> myString;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  16:</span>    <span style="color: #0000ff">public</span> MyStruct( <span style="color: #0000ff">int</span> aInt ) </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  17:</span>    {      myInt = aInt;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  18:</span>    }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  19:</span> }</pre>
</p></div>
</div>
<p>A class is permitted to declare a destructor.But a struct is not permitted to declare a destructor.<br />
  </p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #0000ff">struct</span> MyStruct</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> {    </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span>   <span style="color: #0000ff">int</span> myInt;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span>   <span style="color: #0000ff">public</span> MyStruct( )   </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span>   {    }    ~MyStruct( )   <span style="color: #008000">//Error.</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span>   {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span>     Console.WriteLine(<span style="color: #006080">&quot;Destructor of MyStruct object&quot;</span>);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span>   }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   9:</span> } </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  10:</span> <span style="color: #0000ff">class</span> MyClass</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  11:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  12:</span>     <span style="color: #0000ff">int</span> myInt;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  13:</span>     <span style="color: #0000ff">public</span> MyClass( )    {    }    ~MyClass( ) <span style="color: #008000">// No Error.</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  14:</span>     {  </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  15:</span>        Console.WriteLine(<span style="color: #006080">&quot;Destructor of MyClass object&quot;</span>);      </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  16:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">  17:</span> } </pre>
</p></div>
</div>
<p>Classes are used for complex and large set data. structs are simple to use. structs are useful whenever you&#160; need a type that will be used often and is mostly just a piece of data. </p>
<p><b>2. What does the term immutable mean?<br />
    <br />Ans. </b>It means to create a view of data that is not modifiable and is temporary of data that is modifiable. </p>
<p>Immutable means you can&#8217;t change the currrent data, but if you perform some operation on that data, a new copy is created. The operation doesn&#8217;t change the data itself. Like let&#8217;s say you have a string object having &quot;hello&quot; value. Now if you say </p>
<p>temp = temp + &quot;new value&quot; </p>
<p>a new object is created, and values is saved in that. The temp object is immutable, and can&#8217;t be changed. </p>
<p>An object qualifies as being called immutable if its value cannot be modified once it has been created. For example,&#160; methods that appear to modify a String actually return a new String containing the modification.&#160; Developers are modifying strings all the time in their code.&#160; This may appear to the developer as mutable &#8211; but it is not.&#160; What actually happens is your string variable/object has been changed to reference a new string value containing the results of your new string value.&#160; For this very reason .NET has the System.Text.StringBuilder class.&#160; If you find it necessary to modify the actual contents of a string-like object heavily, such as in a for or foreach loop, use the System.Text.StringBuilder class. </p>
<p><b></b></p>
<p><b>3. Can we have private constructor? When can I use them? When should we implement a private constructor?</b> </p>
<p><b>Ans.</b> Private constructors would be mainly used for singleton patterns and for classes that are module-like (only static/shared methods/attributes) </p>
<p>The idea of the singleton is that you don&#8217;t have a public constructor, specifically to prevent people from instantiating more than one of them. You call a non-constructor method to return the singleton instance. If it doesn&#8217;t exist, the method calls the private constructor to create it. Then it returns a reference to the singleton instance. </p>
<p>An example below&#8230;</p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #008000">// .NET Singleton</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> <span style="color: #0000ff">sealed</span> <span style="color: #0000ff">class</span> Singleton </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span>  <span style="color: #0000ff">private</span> Singleton() {}</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span>  <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">readonly</span> Singleton Instance = <span style="color: #0000ff">new</span> Singleton();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span> } </pre>
</p></div>
</div>
<p>Obviously you&#8217;d need to add some properties and methods to get something useful, but you get the idea. Watch out for thread safety issues.<br />
  <br />This link may give more insight: </p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ImpSingletonInCsharp.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ImpSingletonInCsharp.asp</a> </pre>
</p></div>
</div>
<p><b>4.Explain the differences between Server-side and Client-side code?<br />
    <br />Ans.</b> Server side code will execute at server end all the business logic will execute at server end </p>
<p>where as client side code will execute at client side at browser end. Usually, scripts like Javascript, </p>
<p>VBScript &amp; JScript etc. take care of client side funtions. </p>
<p><b></b></p>
<p><b>5. What type of code (server or client) is found in a Code-Behind class?<br />
    <br />Ans.</b> Server side. </p>
<p><b></b></p>
<p><b>6.Should validation (Did the user enter a real date?) occur server-side or client-side? Why?<br />
    <br />Ans.</b> Ideally it should occur client-side. It saves round-trip to server &amp; thus saves time!!!&#160; It also avoids SQL Injections from malicious users. SQL injection is a security vulnerability that occurs in the database layer of an application. The vulnerability is present when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and thereby unexpectedly executed. It is in fact an instance of a more general class of vulnerabilities that can occur whenever one programming or scripting language is embedded inside another. Validation is usually done using client-side script like javascript, jscript, vbscript (javascript being the most popular due to browser compatibility). </p>
<p>.NET provides 5 + 1 controls for validation </p>
<p><b>1- RequiredFieldValidator<br />
    <br />2- RangeValidator </p>
<p>3- RegularExpressionValidator </p>
<p>4- CompareValidator </p>
<p>5- CustomValidator and the ValidationSummary Control </b></p>
<p><b></b></p>
<p><b>7.What does the &quot;EnableViewState&quot; property do? Why would I want it on or off?<br />
    <br />Ans.</b> It keeps the data of the control during post backs. if we turn off, the values should not populate during server round trip. Basically its used to sustain value of control&#8217;s attributes betwen postbacks. </p>
<p>When a form is submitted in classic ASP, all form values are cleared. Suppose you have submitted a form with a lot of information and the server comes back with an error. You will have to go back to the form and correct the information. You click the back button, and what happens&#8230;&#8230;. </p>
<p>ALL form values are CLEARED, and you will have to start all over again! The site did not maintain your ViewState. When a form is submitted in ASP .NET, the form reappears in the browser window together with all form values. How come? This is because ASP .NET maintains your ViewState. The ViewState indicates the status of the page when submitted to the server. The status is defined through a hidden field placed on each page with a &lt;form runat=&quot;server&quot;&gt; control. Maintaining the ViewState is the default setting for ASP.NET Web Forms. If you want to NOT maintain the ViewState, include the directive &lt;%@ Page EnableViewState=&quot;false&quot; %&gt; at the top of an .aspx page or add the attribute EnableViewState=&quot;false&quot; to any control. </p>
<p><b></b></p>
<p><b>8. What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other? </b></p>
<p><b>Ans.</b> Server.Transfer will prevent round trip. it will redirect pages which or in the same directory. NO way to pass the query strings . Thru http context we can able to get the previous page control values. </p>
<p>Response.Redirect : There is a round trip to process the request. We can redirect to any page external / internal other than aspx. We can pass the query string thru which wecan manage sessions. A common misconception is the difference between Server.Transfer and Response.Redirect in ASP.NET applications. Redirect and Transfer both cause a new page to be processed, but the interaction between the client (web browser) and server (ASP.NET) is different in each situation. Redirect: A redirect is just a suggestion – it&#8217;s like saying to the client &quot;Hey, you might want to look at this&quot;. All you tell the client is the new URL to look at, and if they comply, they do a second request for the new URL. </p>
<p>If you want to pass state from the source page to the new page, you have to pass it either on the URL (such as a database key, or message string), or you can store it in the Session object (caveat: there may be more than one browser window, and they&#8217;ll all use the same session object). <b>e.g. </b>Redirect to the new.aspx page, passing an ID on the query string. &quot;true&quot; stops processing the current page: </p>
<p>Response.Redirect(&quot;new.aspx?id=32&quot;, true); Transfer: A transfer happens without the client knowing </p>
<p>– it&#8217;s the equivalent of a client requesting one page, but being given another. As far as the client knows, they are still visiting the original URL. Sharing state between pages is much easier using </p>
<p>Server.Transfer – you can put values into the Context.Items dictionary, which is similar to Session and Application, except that it lasts only for the current request. (search for HttpContext in MSDN). The page receiving postback can process data, store values in the Context, and then Transfer to a page that uses the values. e.g. Store a message in the context dictionary, and transfer to the default.aspx page (which can then display the message): </p>
<p></p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> Context.Items[<span style="color: #006080">&quot;Message&quot;</span>] = <span style="color: #006080">&quot;Your password was changed successfully&quot;</span>;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> Server.Transfer(<span style="color: #006080">&quot;default.aspx&quot;</span>); </pre>
</p></div>
</div>
<p>Response.Redirect is more user-friendly, as the site visitor can bookmark the page that they are redirected to. Transferred pages appear to the client as a different url than they really are. This means that things like relative links/image paths may not work if you transfer to a page from a different directory. Server.Transfer has an optional parameter to pass the form data to the new page. Since the release version, this no longer works, because the Viewstate now has more security by default (The<br />
  <br />EnableViewStateMac defaults to true), so the new page isn&#8217;t able to access the form data. You can still access the values of the original page in the new page, by requesting the original handler: </p>
<p></p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> Page originalPage = (Page)Context.Handler; </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> TextBox textBox1 = (TextBox)originalPage.FindControl(<span style="color: #006080">&quot;textBox1&quot;</span>); </pre>
</p></div>
</div>
<p><b></b></p>
<p><b>9. Can you give an example of when it would be appropriate to use a web service as opposed to a non-serviced .NET component.<br />
    <br />Ans. </b>Web service is one of main component in Service Oriented Architecture. You could use web services when your clients and servers are running on different networks and also different latforms. This provides a loosely coupled system. And also if the client is behind the firewall it would be easy to use web service since it runs on port 80 (by default) instead of having some thing else in Service Oriented Architecture applications. </p>
<p><b>What is the standard you use to wrap up a call to a Web service?</b> </p>
<p><b>Ans. </b>SOAP. </p>
<p>Web services are best suite for Hetrogenious environment. Remoting is best suite for Homogenious environment where the system is under CLR. </p>
<p><b></b></p>
<p><b>10. Let&#8217;s say I have an existing application written using Visual Studio 6 (VB 6, InterDev 6) and this application utilizes Windows 2000 COM+ transaction services. How would you approach migrating this application to .NET? </b></p>
<p><b>Ans. </b>.NET has made excellent use of the existing COM+ Technology to provide component features like instance management, transactions, activity-based synchronization, granular role-based security, disconnected asynchronous queued components, and loosely coupled events. This integration is a </p>
<p>big leap forward, providing greater flexibility to developers through code. The .NET components, which make use of the COM+ Services, are termed as ServicedComponents. Must read this link to learn more : http://msdn2.microsoft.com/en-us/library/ms973809.aspx </p>
<p><b></b></p>
<p><b>11. Can you explain the difference between an </b><b>ADO.NET</b> Dataset and ADO Recordset? </p>
<p>Ans. In ADO, the in-memory representation of data is the recordset. In ADO.NET, it is the dataset. There are important differences between them. </p>
<p><b>Number of Tables</b> </p>
<p>A recordset looks like a single table. If a recordset is to contain data from multiple database tables, it must use a JOIN query, which assembles the data from the various database tables into a single result table. In contrast, a dataset is a collection of one or more tables. The tables within a dataset are called data tables; specifically, they are DataTable objects. If a dataset contains data from multiple database tables, it will typically contain multiple DataTable objects. That is, each DataTable object typically corresponds to a single database table or view. In this way, a dataset can mimic the structure of the underlying database. </p>
<p>A dataset usually also contains relationships. A relationship within a dataset is analogous to a foreign-key relationship in a database —that is, it associates rows of the tables with each other. For example, if a dataset contains a table about investors and another table about each investor&#8217;s stock purchases, it could also contain a relationship connecting each row of the investor table with the corresponding rows of the purchase table. Because the dataset can hold multiple, separate tables and maintain information about relationships between them, it can hold much richer data structures than a recordset, including self-relating tables and tables with many-to-many relationships. </p>
<p><b>Data Navigation and Cursors</b> </p>
<p>In ADO you scan sequentially through the rows of the recordset using the ADO MoveNext method. In ADO.NET, rows are represented as collections, so you can loop through a table as you would through any collection, or access particular rows via ordinal or primary key index. DataRelation objects maintain information about master and detail records and provide a method that allows you to get records related to the one you are working with. For example, starting from the row of the Investor table for &quot;Nate Sun,&quot; you can navigate to the set of rows of the Purchase table describing his purchases. </p>
<p>A cursor is a database element that controls record navigation, the ability to update data, and the visibility of changes made to the database by other users. ADO.NET does not have an inherent cursor object, but instead includes data classes that provide the functionality of a traditional cursor. For example, the functionality of a forward-only, read-only cursor is available in the ADO.NET DataReader object. For more information about cursor unctionality, see Data Access Technologies. </p>
<p><b>Minimized Open Connections</b> </p>
<p>In ADO.NET you open connections only long enough to perform a database operation, such as a Select or Update. You can read rows into a dataset and then work with them without staying connected to the data source. In ADO the recordset can provide disconnected access, but ADO is designed primarily for connected access. </p>
<p>There is one significant difference between disconnected processing in ADO and ADO.NET. In ADO you communicate with the database by making calls to an OLE DB provider. In ADO.NET you communicate with the database through a data adapter (an OleDbDataAdapter, SqlDataAdapter, OdbcDataAdapter, or OracleDataAdapter object), which makes calls to an OLE DB provider or the APIs provided by the underlying data source. The important difference is that in ADO.NET the data adapter allows you to control how the changes to the dataset are transmitted to the database — by optimizing for performance, performing data validation checks, or adding any other extra processing. </p>
<p><b>Note -</b>&#160;&#160; Data adapters, data connections, data commands, and data readers are the components that make up a .NET Framework data provider. Microsoft and third-party providers can make available other .NET Framework data providers that can be integrated into Visual Studio. For information on the different .NET Data providers, see .NET Data Providers. </p>
<p><b>Sharing Data Between Applications</b> </p>
<p>Transmitting an ADO.NET dataset between applications is much easier than transmitting an ADO disconnected recordset. To transmit an ADO disconnected recordset from one component to another, you use COM marshalling. To transmit data in ADO.NET, you use a dataset, which can transmit an XML stream. </p>
<p><b></b></p>
<p><b>12.&#160; Can you give an example of what might be best suited to place in the Application_Start and Session_Start subroutines?&#160; </b></p>
<p><b>Ans.</b> The Application_Start event is guaranteed to occur only once throughout the lifetime of the application. It&#8217;s a good place to initialize global variables. For example, you might want to retrieve a list of products from a database table and place the list in application state or the Cache object. SessionStateModule exposes both Session_Start and Session_End events. </p>
<p><b></b></p>
<p><b>13. If I&#8217;m developing an application that must accomodate multiple security levels through secure login and my </b><b>ASP.NET</b> web appplication is spanned across three web-servers (using round-robbin load balancing) what would be the best approach to maintain login-in state </p>
<p>for the users? </p>
<p>Ans. Database Support OR through State Service </p>
<p><b></b></p>
<p><b>14. What are </b><b>ASP.NET</b> Web Forms? How is this technology different than what is available though ASP (1.0-3.0)? </p>
<p>Ans. There are plenty of differences. ASP Interpreter.. use the script engine. ASP.Net is compiled as managed code within the CLR. It also supports code-behind (unlike in ASP, where code=behind was </p>
<p>invoked through VB components). </p>
<p><b></b></p>
<p><b>15. How does </b><b>VB.NET/C#</b> achieve polymorphism? </p>
<p>Ans. We achieve it using Function overloading &amp; Operator overloading. </p>
<p>Polymorphism by definition means taking many forms. In C# it means the ability for classes to share the same methods (actions) but implement them differently. For instance, say we create a class called &quot;Shape&quot; and this class has a method called .draw() which draws the shape onto the user interface. Then we create two subclasses, using inheritance, of this Shape class. One called Square, the other called Circle. Now obviously a square and circle are two entirely different shapes, yet both classes have the .draw() method. When the Square.draw() method is called it will draw a square on the user interface. When the Circle.draw() method is called, it will draw a circle on the user interface. So both classes can use the same methods but implement them differently. </p>
<p><b></b></p>
<p><b>16. Can you explain what inheritance is and an example of when you might use it? </b></p>
<p><b>Ans.</b> Inheriting a trait from a parent class! Use the existing functionality along with its own properities. </p>
<p><b></b></p>
<p><b>17.</b> How would you implement inheritance using VB.NET/C#? </p>
<p><b>Ans.</b> Derived Class : Baseclass </p>
<p>VB.NET : Derived Class Inherits Baseclass </p>
<p><b></b></p>
<p><b>18. Whats an assembly ?<br />
    <br />Ans.</b> A Basic unit of executable code.&#160; <br />&#160; * It contains : Manifest &#8211; Meta data </p>
<p>&#160; * versioning , Culture , IL, Reference </p>
<p><b></b></p>
<p><b>19. Describe the difference between inline and code behind. </b></p>
<p><b>Ans.</b> Inline function bind at compile time can write in aspx page with in &lt;% %&gt; . </p>
<p>The code-behind is in a CS or a VB file. </p>
<p><b></b></p>
<p><b>20. Explain what a diffgram is, and a good use for one.<br />
    <br />Ans. </b>A DiffGram is an XML format that is used to identify current and original versions of data elements. The DataSet uses the DiffGram format to load and persist its contents, and to serialize its contents for transport across a network connection. When a DataSet is written as a DiffGram, it populates the DiffGram with all the necessary information to accurately recreate the contents, though not the schema, of the DataSet, including column values from both the Original and Current row versions, row error information, and row order. When sending and retrieving a DataSet from an XML Web service, the DiffGram format is implicitly used. </p>
<p>Additionally, when loading the contents of a DataSet from XML using the ReadXml method, or when writing the contents of a DataSet in XML using the WriteXml method, you can select that the contents be read or written as a DiffGram </p>
<p><b>DiffGram Format<br />
    <br /></b>The DiffGram format is divided into three sections: the current data, the original (or &quot;before&quot;) data, and an errors section, as shown in the following example. </p>
<p></p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #0000ff">&lt;?</span><span style="color: #800000">xml</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">=&quot;1.0&quot;</span>?<span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">diffgr:diffgram</span> <span style="color: #ff0000">xmlns:msdata</span><span style="color: #0000ff">=&quot;urn:schemas-microsoft-com:xml-msdata&quot;</span> <span style="color: #ff0000">xmlns:diffgr</span><span style="color: #0000ff">=&quot;urn:schemas-microsoft-com:xml-diffgram-v1&quot;</span> <span style="color: #ff0000">xmlns:xsd</span><span style="color: #0000ff">=&quot;http://www.w3.org/2001/XMLSchema&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">DataInstance</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">DataInstance</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">diffgr:before</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">diffgr:before</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">diffgr:errors</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">diffgr:errors</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">diffgr:diffgram</span><span style="color: #0000ff">&gt;</span></pre>
</p></div>
</div>
<p>The DiffGram format consists of the following blocks of data:<br />
  <br />&lt;DataInstance&gt; </p>
<p>The name of this element, DataInstance, is used for explanation purposes in this documentation. A DataInstance element represents a DataSet or a row of a DataTable. Instead of DataInstance, the element would contain the name of the DataSet or DataTable. This block of the DiffGram format contains the current data, whether it has been modified or not. An element, or row, that has been modified is identified with the diffgr:hasChanges annotation. </p>
<p>&lt;diffgr:before&gt; </p>
<p>This block of the DiffGram format contains the original version of a row. Elements in this block are matched to elements in the DataInstance block using the diffgr:id annotation. </p>
<p>&lt;diffgr:errors&gt; </p>
<p>This block of the DiffGram format contains error information for a particular row in the DataInstance block. Elements in this block are matched to elements in the DataInstance block using the diffgr:id annotation. </p>
<p><b></b></p>
<p><b>21. Where would you use an iHTTPModule, and what are the limitations of any approach you might take in implementing one? </b></p>
<p><b>Ans. </b>It provides module initialization and disposal events </p>
<p>to the implementing class. </p>
<p><b></b></p>
<p><b>22. Compare Session State Vs. ViewState.<br />
    <br />Ans. </b>Session State is useful for storing values that must be persisted across multiple pages by the same user. ViewState is useful for storing serializable data that must be </p>
<p>persisisted across PostBacks by a single page. If you use Session State, the value you insert will remain in memory until (1) The Session times out, or (2) Your code removes it.&#160; If you use ViewState, the value you insert will remain in ViewState until the user requests a different page. ViewState stores data betwen PostBacks by putting it into a hidden form field on the client HTML doc. when the doc is Posted Back, the values are read from the hidden form field and stored in memory until the page has finished processing. If ViewState is particularly large (and I&#8217;m talking KBs </p>
<p>here, not 6 bytes), it can negatively affect the speed at which the HTML doc is downloaded by the browser. </p>
<p><b></b></p>
<p><b>24. Whats MSIL, and why should my developers need an appreciation of it if at all? </b></p>
<p><b>Ans.</b> Microsoft Intermediate language. which is the out put for all the .net supported languages after compilation will produce. Appreciation is for cross language support. Definition:Microsoft Intermediate Language (MSIL) is the CPU-independent instruction set generated by .NET compilers from .NET languages such as J#, C# or Visual Basic. MSIL is compiled before or during execution of the program by a Virtual Execution System (VES), which is part of the Common Language Runtime module (CLR). </p>
<p><b></b></p>
<p><b>25. In what order do the events of an ASPX page execute. As a developer is it important to undertsand these events?<br />
    <br />Ans. </b></p>
<p><b>Page request<br />
    <br /></b>The page request occurs before the page life cycle begins. When the page is requested by a user, <a href="http://asp.net/">ASP.NET</a> determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page. </p>
<p><b>Start </b></p>
<p>In the start step, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. Additionally, during the start step, the page&#8217;s UICulture property is set. </p>
<p><b>Page initialization<br />
    <br /></b>During page initialization, controls on the page are available and each control&#8217;s UniqueID property is set. Any themes are also applied to the page. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state. </p>
<p><b>Load<br />
    <br /></b>During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state. </p>
<p><b>Validation<br />
    <br /></b>During validation, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page. </p>
<p><b>Postback event handling<br />
    <br /></b>If the request is a postback, any event handlers are called. Rendering&#160; Before rendering, view state is saved for the page and all controls. During the rendering phase, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream of the page&#8217;s Response property. </p>
<p><b>Unload</b> </p>
<p>Unload is called after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and any cleanup is performed. </p>
<p><b></b></p>
<p><b>26. Which method do you invoke on the DataAdapter control to load your generated dataset with data?<br />
    <br />Ans.</b> Fill() </p>
<p><b></b></p>
<p><b>27.</b> Can you edit data in the Repeater control? </p>
<p><b>Ans. </b>NO </p>
<p><b></b></p>
<p><b>28.</b> Which template must you provide, in order to display data in a Repeater control? </p>
<p><b>Ans. </b>ITemtemplate </p>
<p><b></b></p>
<p><b>29. How can you provide an alternating color scheme in a Repeatercontrol? </b></p>
<p><b>Ans.</b> AlternateItemTemplate </p>
<p><b></b></p>
<p><b>30. What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeatercontrol? </b></p>
<p><b>Ans.</b> Datasource, DataBind </p>
<p><b></b></p>
<p><b>31. What base class do all Web Forms inherit from?<br />
    <br />Ans. </b>System.Web.UI.Page </p>
<p><b></b></p>
<p><b>32. What method do you use to explicitly kill a user&#8217;s session?<br />
    <br />Ans.</b> Abandon() </p>
<p><b></b></p>
<p><b>33. How do you turn off cookies for one page in your site?<br />
    <br />Ans.</b> Disablecookies. </p>
<p><b></b></p>
<p><b>34. Which two properties are on every validation control?<br />
    <br />Ans. </b>Control to validate, Error message </p>
<p><b></b></p>
<p><b>35. What tags do you need to add within the asp:datagrid tags to bind columns manually?<br />
    <br />Ans.</b> autogenerated columns is set to false </p>
<p><b></b></p>
<p><b>36. How do you create a permanent cookie?<br />
    <br />Ans.&#160; </b>Setting a permanent cookie is no harder than setting a Session cookie. It&#8217;s very similar, except you give the cookie an expiration date as well. It is very common that you don&#8217;t specify any arbitrary expiration date, but instead expire the cookie relative to the current date, using the DateAdd() function, built into ASP. If you want to create a permanent cookie called Name with a value of Nigel, which expires in one </p>
<p>month, you&#8217;d use the following code </p>
<p></p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> Response.Cookies(<span style="color: #006080">&quot;Name&quot;</span>) = <span style="color: #006080">&quot;Nigel&quot;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> Response.Cookies(<span style="color: #006080">&quot;Name&quot;</span>).Expires = DateAdd(<span style="color: #006080">&quot;m&quot;</span>, 1, Now()) </pre>
</p></div>
</div>
<p>It&#8217;s that easy! Nothing more to it. You have now set a permanent cookie on your computer. Also, note that whenever the above code is called the expiration date of the cookie is renewed by one month from now.<br />
  <br />There are a few more options which you can set, like for example the Path option. You can limit cookies to certain paths on your website, so you can set several cookies with the same name, as long as they belong to different paths. To do this, you would use the following code (extending the previous code): </p>
<p>Response.Cookies(&quot;Name&quot;).Path = &quot;/foo/&quot; </p>
<p>The above code would limit the cookie to the path foo. It is also possible to assign multiple values to a particular cookie. This is done using the so-called dictionary functionality of a cookie. For example, if I&#8217;d want to store not only the first name, but also the surname in my Name cookie, I&#8217;d be using something like the following code: </p>
<p></p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> Response.Cookies(<span style="color: #006080">&quot;Name&quot;</span>)(<span style="color: #006080">&quot;First&quot;</span>) = <span style="color: #006080">&quot;Nigel&quot;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> Response.Cookies(<span style="color: #006080">&quot;Name&quot;</span>)(<span style="color: #006080">&quot;Last&quot;</span>) = <span style="color: #006080">&quot;Pallett&quot;</span> </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span> Response.Cookies(<span style="color: #006080">&quot;Name&quot;</span>).Expires = DateAdd(<span style="color: #006080">&quot;m&quot;</span>, 1, Now()) </pre>
</p></div>
</div>
<p>That&#8217;s all! Although there are a few more &quot;advanced&quot; options, such as the Secure option and the Domain option, it is of no use now.<br />
  <br /><b>Retrieving Cookies</b> </p>
<p>Retrieving the value of cookies is a very easy job, because again everything is handled by the browser and your server. All you have to use is ASP&#8217;s inbuilt functions. There is no difference in retrieving a Session cookie or a permanent cookie, and in both cases you use the following code: </p>
<p></p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> Response.Write <span style="color: #006080">&quot;Your Name: &quot;</span> &amp; Request.Cookies(<span style="color: #006080">&quot;Name&quot;</span>) </pre>
</p></div>
</div>
<p>The above is for when you assigned only one value to a cookie. If you assigned multiple values you a cookie, you use the following code:<br />
  </p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> Response.Write <span style="color: #006080">&quot;Your First Name: &quot;</span> &amp; Request.Cookies(<span style="color: #006080">&quot;Name&quot;</span>)(<span style="color: #006080">&quot;First&quot;</span>)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> Response.Write <span style="color: #006080">&quot;Your Surname: &quot;</span> &amp; Request.Cookies(<span style="color: #006080">&quot;Name&quot;</span>)(<span style="color: #006080">&quot;Last&quot;</span>) </pre>
</p></div>
</div>
<p>That&#8217;s all there is to it. It&#8217;s that easy, because everything is done by your server and the ASP engine. Make sure you check out this handy function as well, which shows your visitors all the cookies they have stored.<br />
  <br />Checking if Cookies are enabled Before using cookies, it is often useful to check whether your visitor accepts cookies. Some may disable it in their browser; </p>
<p>others may be using browsers that don&#8217;t support cookies at all (although very few browsers do). You should always keep the fact that your cookies might not work in the back of your mind, meaning, do NOT rely on cookies to work. If your website does not work when cookies are disabled, you must fix this. </p>
<p><b></b></p>
<p><b>37. What tag do you use to add a hyperlink column to the DataGrid? </b></p>
<p><b>Ans.</b></p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">asp:HyperLink</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;some_Id_uDefine&quot;</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">=&quot;server&quot;</span><span style="color: #0000ff">&gt;</span> </pre>
</p></div>
</div>
<p><b></b></p>
<p><b>38. What is the standard you use to wrap up a call to a Web service? </b></p>
<p><b>Ans.</b> SOAP &#8211; SOAP is a simple XML-based protocol to let applications exchange information over HTTP. SOAP (originally Simple Object Access Protocol) is a </p>
<p>protocol for exchanging XML-based messages over computer network, normally using HTTP. SOAP forms the foundation layer of the Web services stack, providing a basic messaging framework that more abstract layers can build on. The original acronym was dropped with Version 1.2 of the standard, which became a W3C Recommendation on June 24, 2003, as it was considered to be misleading. </p>
<p>There are several different types of messaging patterns in SOAP, but by far the most common is the Remote Procedure Call (RPC) pattern, in which one network node (the client) sends a request message to another node (the server), and the server immediately sends a response message to the client. SOAP is the successor of XML-RPC, though it borrows its transport and interaction neutrality and the envelope/header/body from elsewhere, probably from WDDX [citation needed]. Originally designed by Dave Winer, Don Box, Bob Atkinson, and Mohsen Al-Ghosein in 1998 with backing from Microsoft (where Atkinson and Al-Ghosein worked at the time) as an object-access protocol, the SOAP specification is currently maintained by the XML Protocol Working Group of the World Wide Web Consortium. </p>
<p><b></b></p>
<p><b>39. Which method do you use to redirect the user to another page without performing a round trip to the client? </b></p>
<p><b>Ans.</b> Server.transfer </p>
<p><b></b></p>
<p><b>40. What is the transport protocol you use to call a Web service&#160; <br />Ans.</b> </p>
<p>SOAP. Transport Protocols: It is essential for the acceptance of Web Services that they are based on established Internet infrastructure. This in fact imposes the usage of of the HTTP, SMTP and FTP protocols based on the TCP/IP family of transports. Messaging Protocol: The format of messages exchanged between Web Services clients and Web Services should be vendor neutral and should not carry details about the technology used to implement the service. Also, the message format should allow for extensions and different bindings to specific transport protocols. SOAP and ebXML Transport are specifications which fulfill these requirements. We expect that the W3C XML Protocol Working Group defines a successor standard. </p>
<p><b></b></p>
<p><b>41. True or False: A Web service can only be written in .NET<br />
    <br />Ans. </b>False </p>
<p><b></b></p>
<p><b>42. What does WSDL stand for?<br />
    <br />Ans.</b>Webservice description language. WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). WSDL is extensible to allow description of endpoints and their messages regardless of what message formats or network protocols are used to communicate, however, the only bindings described in this document describe how to use WSDL in conjunction with SOAP 1.1, HTTP GET/POST, and MIME. </p>
<p><b></b></p>
<p><b>43. What property do you have to set to tell the grid which page to go to when using the Pager object?<br />
    <br />Ans. </b>Page Index. </p>
<p><b></b></p>
<p><b>44. Where on the Internet would you look for Web services?<br />
    <br />Ans. </b>UDDI </p>
<p><b></b></p>
<p><b>45. What tags do you need to add within the asp:datagrid tags to bind columns manually. </b></p>
<p><b>Ans. </b>Autogenerate columns </p>
<p><b></b></p>
<p><b>46. Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box?<br />
    <br />Ans. </b>Datatext, Datavalue </p>
<p><b></b></p>
<p><b>47. How is a property designated as read-only?<br />
    <br />Ans. </b></p>
<p>In VB.NET: </p>
<p></p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #0000ff">Public</span> <span style="color: #0000ff">ReadOnly</span> <span style="color: #0000ff">Property</span> PropertyName <span style="color: #0000ff">As</span> ReturnType</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span>  <span style="color: #0000ff">Get</span>   <span style="color: #008000">'Your Property Implementation goes in here</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span>  <span style="color: #0000ff">End</span> <span style="color: #0000ff">Get</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span> <span style="color: #0000ff">End</span> <span style="color: #0000ff">Property</span> </pre>
</p></div>
</div>
<p>
  <br />In C# </p>
<p></p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #0000ff">public</span> returntype PropertyName</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span>  get{</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span>   <span style="color: #008000">//property implementation goes here</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span>  }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span>  <span style="color: #008000">// Do not write the set implementation</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span> } </pre>
</p></div>
</div>
<p><b></b></p>
<p><b>48. Which control would you use if you needed to make sure the values in two different controls matched?<br />
    <br />Ans.</b> Ideally we would tend to use Comparefield validator. </p>
<p><b></b></p>
<p><b>49. True or False: To test a Web service you must create a windows application or Web application to consume this service?<br />
    <br />Ans.</b> False </p>
<p><b></b></p>
<p><b>50. How many classes can a single .NET DLL contain?<br />
    <br />Ans. </b>As many as u want! </p>
<p><b>51.</b> <b>Is </b><b>ASP.NET</b> a language? </p>
<p>Ans. No! Its a technology. </p>
<p>ASP.NET is not a platform independent language. As was ASP.NET is more of a technology that provides a framework for building web applications. ASP.NET provides the reources needed to dynamically deliver html content (pages) to the end user. ASP.NET can leverage languages such as C#, VB.NET, and javascript to help provide a reliable, high perfofmance, and secure web application. </p>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text=".NET Interview Questions" data-url="http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET Interview Questions #2</title>
		<link>http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions-2/</link>
		<comments>http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions-2/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 03:54:17 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[Interview Questions - .NET]]></category>
		<category><![CDATA[.NET Interview Questions]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=21</guid>
		<description><![CDATA[Collected from the Internet: General Questions 1.&#160;&#160; Does C# support multiple-inheritance? No. 2.&#160;&#160; Who is a protected class-level variable available to? It is available to any sub-class (a class inheriting this class). 3.&#160;&#160; Are private class-level variables inherited? Yes, but they are not accessible.&#160; Although they are not visible or accessible via the class interface, [...]]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions-2/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions-2/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text=".NET Interview Questions #2" data-url="http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions-2/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<p><b>Collected from the Internet:</b>     <br /><b></b></p>
<h3>General Questions</h3>
<p> <b></b>
<p><b></b></p>
<p><b>1.&#160;&#160; Does C# support multiple-inheritance?</b>     <br />No.     <br /><b>2.&#160;&#160; Who is a protected class-level variable available to?      <br /></b>It is available to any sub-class (a class inheriting this class).     <br /><b>3.&#160;&#160; Are private class-level variables inherited?      <br /></b>Yes, but they are not accessible.&#160; Although they are not visible or accessible via the class interface, they are inherited.&#160; <br /><b>4.&#160;&#160; Describe the accessibility modifier &quot;protected internal&quot;.      <br /></b>It is available to classes that are within the same assembly and derived from the specified base class.&#160; <br /><b>5.&#160;&#160; What&#8217;s the top .NET class that everything is derived from? </b>    <br />System.Object.&#160; <br /><b>6.&#160;&#160; What does the term immutable mean?</b>     <br />The data value may not be changed.&#160; Note: The <i>variable</i> value may be changed, but the original immutable data value was discarded and a new data value was created in memory.&#160;&#160; <br /><b>7.&#160;&#160; What&#8217;s the difference between System.String and System.Text.StringBuilder classes?</b>     <br />System.String is immutable.&#160; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.&#160; <br /><b>8.&#160;&#160; What&#8217;s the advantage of using System.Text.StringBuilder over System.String?</b>     <br />StringBuilder is more efficient in cases where there is a large amount of string manipulation.&#160; Strings are immutable, so each time a string is changed, a new instance in memory is created.     <br /><b>9.&#160;&#160; Can you store multiple data types in System.Array?</b>     <br />No.&#160; <br /><b>10. What&#8217;s the difference between the System.Array.CopyTo() and System.Array.Clone()?      <br /></b>The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array.&#160; The CopyTo() method copies the elements into another existing array.&#160; Both perform a shallow copy.&#160; A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array.&#160; A deep copy (which neither of these methods performs) would create a new instance of each element&#8217;s object, resulting in a different, yet identacle object.     <br /><b>11.&#160; How can you sort the elements of the array in descending order?      <br /></b>By calling Sort() and then Reverse() methods.&#160; <br /><b>12.&#160; What&#8217;s the .NET collection class that allows an element to be accessed using a unique key?      <br /></b>HashTable.&#160; <br /><b>13.&#160; What class is underneath the SortedList class?      <br /></b>A sorted HashTable.&#160; <br /><b>14.&#160; Will the finally block get executed if an exception has not occurred?­      <br /></b>Yes.     <br /><b>15.&#160; What&#8217;s the C# syntax to catch any possible exception?      <br /></b>A catch block that catches the exception of type System.Exception.&#160; You can also omit the parameter data type in this case and just write catch {}.&#160; <br /><b>16.&#160; Can multiple catch blocks be executed for a single try statement?      <br /></b>No.&#160; Once the proper catch block processed, control is transferred to the finally block (if there are any).&#160; <br /><b>17.&#160; Explain the three services model commonly know as a three-tier application.      <br /></b>Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).&#160; </p>
<p> <b></b>
<p><b></b></p>
<h3><b>Class Questions</b></h3>
<p> 
<p><b></b><b>1.&#160;&#160; What is the syntax to inherit from a class in C#?      <br /></b>Place a colon and then the name of the base class.     <br />Example: <i>class MyNewClass : MyBaseClass</i>     <br /><b>2.&#160;&#160; Can you prevent your class from being inherited by another class?      <br /></b>Yes.&#160; The keyword &quot;sealed&quot; will prevent the class from being inherited.&#160; <br /><b>3.&#160;&#160; Can you allow a class to be inherited, but prevent the method from being over-ridden?      <br /></b>Yes.&#160; Just leave the class public and make the method sealed.&#160; <br /><b>4.&#160;&#160; What&#8217;s an abstract class?      <br /></b>A class that cannot be instantiated.&#160; An abstract class is a class that must be inherited and have the methods overridden.&#160; An abstract class is essentially a blueprint for a class without any implementation.&#160; <br /><b>5.&#160;&#160; When do you absolutely have to declare a class as abstract?</b>     <br />1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.     <br />2.&#160; When at least one of the methods in the class is abstract.&#160; <br /><b>6.&#160;&#160; What is an interface class?      <br /></b>Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes.&#160; <br /><b>7.&#160;&#160; Why can&#8217;t you specify the accessibility modifier for methods inside the interface?      <br /></b>They all must be public, and are therefore public by default.&#160; <br /><b>8.&#160;&#160; Can you inherit multiple interfaces?      <br /></b>Yes.&#160; .NET does support multiple interfaces.&#160; <br /><b>9.&#160;&#160; What happens if you inherit multiple interfaces and they have conflicting method names?      <br /></b>It&#8217;s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you&#8217;re okay.     <br /><b>To Do:</b> Investigate&#160; <br /><b>10.&#160; What&#8217;s the difference between an interface and abstract class?      <br /></b>In an interface class, all methods are abstract &#8211; there is no implementation.&#160; In an abstract class some methods can be concrete.&#160; In an interface class, no accessibility modifiers are allowed.&#160; An abstract class may have accessibility modifiers.&#160; <br /><b>11.&#160; What is the difference between a Struct and a Class?</b>     <br />Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval.&#160; Another difference is that structs <b>cannot</b> inherit.&#160; </p>
<p> <b></b>
<p><b></b></p>
<h3><b>Method and Property Questions</b></h3>
<p> 
<p><b></b><b>1.&#160;&#160; What&#8217;s the implicit name of the parameter that gets passed into the set method/property of a class?      <br /></b>Value.&#160; The data type of the value parameter is defined by whatever data type the property is declared as.&#160;&#160; <br /><b>2.&#160;&#160; What does the keyword &quot;virtual&quot; declare for a method or property?      <br /></b>The method or property can be overridden.&#160; <br /><b>3.&#160;&#160; How is method overriding different from method overloading?      <br /></b>When overriding a method, you change the behavior of the method for the derived class.&#160; Overloading a method simply involves having another method with the same name within the class.&#160;&#160; <br /><b>4.&#160;&#160; Can you declare an override method to be static if the original method is not static?      <br /></b>No.&#160; The signature of the virtual method must remain the same.&#160; (Note: Only the keyword virtual is changed to keyword override)&#160; <b>5.&#160;&#160; What are the different ways a method can be overloaded?      <br /></b>Different parameter data types, different number of parameters, different order of parameters.&#160; <br /><b>6.&#160;&#160; If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?      <br /></b>Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.     </p>
<p> <b></b>
<p><b></b></p>
<h3><b>Events and Delegates</b></h3>
<p> 
<p><b></b><b>1.&#160;&#160; What&#8217;s a delegate?      <br /></b>A delegate object encapsulates a reference to a method.&#160; <br /><b>2.&#160;&#160; What&#8217;s a multicast delegate?      <br /></b>A delegate that has multiple handlers assigned to it.&#160; Each assigned handler (method) is called.     </p>
<p> <b></b>
<p><b></b></p>
<h3><b>XML Documentation Questions </b></h3>
<p> 
<p><b></b><b>1.&#160;&#160; Is XML case-sensitive?      <br /></b>Yes.&#160; <br /><b>2.&#160;&#160; What&#8217;s the difference between // comments, /* */ comments and /// comments?      <br /></b>Single-line comments, multi-line comments, and XML documentation comments.&#160; <br /><b>3.&#160;&#160; How do you generate documentation from the C# file commented properly with a command-line compiler?      <br /></b>Compile it with the /doc switch.     </p>
<p> <b></b>
<p><b></b></p>
<h3><b>Debugging and Testing Questions </b></h3>
<p> 
<p><b></b><b>1.&#160;&#160; What debugging tools come with the .NET SDK?</b>     <br />1.&#160;&#160; CorDBG – command-line debugger.&#160; To use CorDbg, you must compile the original C# file using the /debug switch.     <br />2.&#160;&#160; DbgCLR – graphic debugger.&#160; Visual Studio .NET uses the DbgCLR.&#160; <br /><b>2.&#160;&#160; What does assert() method do?      <br /></b>In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false.&#160; The program proceeds without any interruption if the condition is true.&#160; <br /><b>3.&#160;&#160; What&#8217;s the difference between the Debug class and Trace class?      <br /></b>Documentation looks the same.&#160; Use Debug class for debug builds, use Trace class for both debug and release builds.&#160; <br /><b>4.&#160;&#160; Why are there five tracing levels in System.Diagnostics.TraceSwitcher?      <br /></b>The tracing dumps can be quite verbose.&#160; For applications that are constantly running you run the risk of overloading the machine and the hard drive.&#160; Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.&#160; <br /><b>5.&#160;&#160; Where is the output of TextWriterTraceListener redirected?</b>     <br />To the Console or a text file depending on the parameter passed to the constructor.&#160; <br /><b>6.&#160;&#160; How do you debug an </b><b>ASP.NET</b> Web application?     <br />Attach the aspnet_wp.exe process to the DbgClr debugger.&#160; <br /><b>7.&#160;&#160; What are three test cases you should go through in unit testing?      <br /></b>1. Positive test cases (correct data, correct output).     <br />2. Negative test cases (broken or missing data, proper handling).     <br />3. Exception test cases (exceptions are thrown and caught properly).&#160; <br /><b>8.&#160;&#160; Can you change the value of a variable while debugging a C# application?      <br /></b>Yes.&#160; If you are debugging via Visual Studio.NET, just go to Immediate window.&#160; </p>
<p> <b></b>
<p><b></b></p>
<h3><b>ADO.NET</b> and Database Questions </h3>
<p> 
<p><b></b><b>1.&#160;&#160; What is the role of the DataReader class in </b><b>ADO.NET</b> connections?     <br />It returns a read-only, forward-only rowset from the data source.&#160; A DataReader provides fast access when a forward-only sequential read is needed.     <br /><b>2.&#160;&#160; What are advantages and disadvantages of Microsoft-provided data provider classes in </b><b>ADO.NET</b>?     <br />SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix.&#160; OLE-DB.NET is a .NET layer on top of the OLE layer, so it&#8217;s not as fastest and efficient as SqlServer.NET.&#160; <br /><b>3.&#160;&#160; What is the wildcard character in SQL?      <br /></b>Let&#8217;s say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve &#8216;La%&#8217;.&#160; <br /><b>4.&#160;&#160; Explain ACID rule of thumb for transactions.      <br /></b>A transaction must be:     <br />1.&#160;&#160; Atomic &#8211; it is one unit of work and does not dependent on previous and following transactions.     <br />2.&#160;&#160; Consistent &#8211; data is either committed or roll back, no &quot;in-between&quot; case where something has been updated and something hasn&#8217;t.     <br />3.&#160;&#160; Isolated &#8211; no transaction sees the intermediate results of the current transaction).     <br />4.&#160;&#160; Durable &#8211; the values persist if the data had been committed even if the system crashes right after.&#160; <br /><b>5.&#160;&#160; What connections does Microsoft SQL Server support?      <br /></b>Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and password).&#160; <b>6.&#160;&#160; Between Windows Authentication and SQL Server Authentication, which one is trusted and which one is untrusted?</b>     <br />Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.&#160; <br /><b>7.&#160;&#160; What does the Initial Catalog parameter define in the connection string?</b>     <br />The database name to connect to.&#160; <br /><b>8.&#160;&#160; What does the Dispose method do with the connection object?      <br /></b>Deletes it from the memory.     <br /><b>To Do:</b> answer better.&#160; The current answer is not entirely correct.&#160; <br /><b>9.&#160;&#160; What is a pre-requisite for connection pooling?</b>     <br />Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings.&#160; The connection string must be identical.     </p>
<p> <b></b>
<p><b></b></p>
<h3><b>Assembly Questions </b></h3>
<p> 
<p><b></b><b>1.&#160;&#160; How is the DLL Hell problem solved in .NET?      <br /></b>Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.&#160; <br /><b>2.&#160;&#160; What are the ways to deploy an assembly?      <br /></b>An MSI installer, a CAB archive, and XCOPY command.&#160; <br /><b>3.&#160;&#160; What is a satellite assembly?</b>     <br />When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.&#160; <br /><b>4.&#160;&#160; What namespaces are necessary to create a localized application?      <br /></b>System.Globalization and System.Resources.     <br /><b>5.&#160;&#160; What is the smallest unit of execution in .NET?</b>     <br />an Assembly.     <br /><b>6.&#160;&#160; When should you call the garbage collector in .NET?</b>     <br />As a good rule, you should not call the garbage collector.&#160; However, you could call the garbage collector when you are done using a large object (or set of objects) to force the garbage collector to dispose of those very large objects from memory.&#160; However, this is usually not a good practice.     <br /><b>7.&#160;&#160; How do you convert a value-type to a reference-type?</b>     <br />Use Boxing.     <br /><b>8.&#160;&#160; What happens in memory when you Box and Unbox a value-type?</b>     <br />Boxing converts a value-type to a reference-type, thus storing the object on the heap.&#160; Unboxing converts a reference-type to a value-type, thus storing the value on the stack. </p>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions-2/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions-2/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text=".NET Interview Questions #2" data-url="http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions-2/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/interview-questions-net/net-interview-questions-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET Assembly Interview Questions</title>
		<link>http://www.ms.oyangudi.com/blog/interview-questions-net/net-assembly-interview-questions/</link>
		<comments>http://www.ms.oyangudi.com/blog/interview-questions-net/net-assembly-interview-questions/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 03:53:32 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[Interview Questions - .NET]]></category>
		<category><![CDATA[.NET Interview Questions]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=20</guid>
		<description><![CDATA[Collected from the Internet: Assembly Questions 1.How is the DLL Hell problem solved in .NET? Ans. Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly. 2.What are the ways to deploy an assembly? Ans. An MSI installer, [...]]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-assembly-interview-questions/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-assembly-interview-questions/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text=".NET Assembly Interview Questions" data-url="http://www.ms.oyangudi.com/blog/interview-questions-net/net-assembly-interview-questions/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<p><b>Collected from the Internet:</b></p>
<p><b>Assembly Questions      <br /></b><b>1.</b>How is the DLL Hell problem solved in .NET?     <br /><b>Ans.</b> Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.     <br /><b>2.</b>What are the ways to deploy an assembly?     <br /><b>Ans.</b> An MSI installer, a CAB archive, and XCOPY command.     <br /><b>3.</b>What is a satellite assembly?     <br /><b>Ans.</b> When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.     <br /><b>4.</b>What namespaces are necessary to create a localized application?     <br /><b>Ans.</b>System.Globalization and System.Resources.     <br /><b>5.</b>What is the smallest unit of execution in .NET?     <br /><b>Ans.</b> an Assembly.     <br /><b>6.</b>When should you call the garbage collector in .NET?     <br /><b>Ans.</b> As a good rule, you should not call the garbage collector.&#160; However, you could call the garbage collector when you are done using a large object (or set of objects)     <br />to force the garbage collector to dispose of those very large objects from memory.&#160; However, this is usually not a good practice.     <br /><b>7.</b>How do you convert a value-type to a reference-type?     <br /><b>Ans.</b> Use Boxing.     <br /><b>8.</b> What happens in memory when you Box and Unbox a value-type?     <br /><b>Ans.</b> Boxing converts a value-type to a reference-type, thus storing the object on the heap.&#160; Unboxing converts a reference-type to a value-type, thus storing the value on     <br />the stack. </p>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-assembly-interview-questions/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-assembly-interview-questions/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text=".NET Assembly Interview Questions" data-url="http://www.ms.oyangudi.com/blog/interview-questions-net/net-assembly-interview-questions/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/interview-questions-net/net-assembly-interview-questions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET Debugging and Testing Questions</title>
		<link>http://www.ms.oyangudi.com/blog/interview-questions-net/net-debugging-and-testing-questions/</link>
		<comments>http://www.ms.oyangudi.com/blog/interview-questions-net/net-debugging-and-testing-questions/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 03:50:30 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[Interview Questions - .NET]]></category>
		<category><![CDATA[.NET Interview Questions]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=17</guid>
		<description><![CDATA[Collected from the Internet: Debugging and Testing Questions 1.What debugging tools come with the .NET SDK? Ans. 1. CorDBG – command-line debugger.&#160; To use CorDbg, you must compile the original C# file using the /debug switch. 2. DbgCLR – graphic debugger.&#160; Visual Studio .NET uses the DbgCLR. 2.What does assert() method do? Ans. In debug [...]]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-debugging-and-testing-questions/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-debugging-and-testing-questions/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text=".NET Debugging and Testing Questions" data-url="http://www.ms.oyangudi.com/blog/interview-questions-net/net-debugging-and-testing-questions/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<p><b>Collected from the Internet:</b>     <br /><b>Debugging and Testing Questions      <br /></b><b>1.</b>What debugging tools come with the .NET SDK?     <br /><b>Ans.      <br /></b>1. CorDBG – command-line debugger.&#160; To use CorDbg, you must compile the original C# file using the /debug switch.     <br />2. DbgCLR – graphic debugger.&#160; Visual Studio .NET uses the DbgCLR.     <br /><b>2.</b>What does assert() method do?     <br /><b>Ans.</b> In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false.&#160; The program proceeds without any interruption if the condition is true.     <br /><b>3.</b>What&#8217;s the difference between the Debug class and Trace class?     <br /><b>Ans.</b> Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.     <br /><b>4.</b>Why are there five tracing levels in System.Diagnostics.TraceSwitcher ?     <br /><b>Ans.</b> The tracing dumps can be quite verbose.&#160; For applications that are constantly running you run the risk of overloading the machine and the hard drive.&#160; Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.     <br /><b>5.</b>Where is the output of TextWriterTraceListener redirected?     <br /><b>Ans.</b> To the Console or a text file depending on the parameter passed to the constructor.     <br /><b>6.</b>How do you debug an ASP.NET Web application?     <br />Ans. Attach the aspnet_wp.exe process to the DbgClr debugger.     <br /><b>7.</b>What are three test cases you should go through in unit testing?     <br /><b>Ans.      <br /></b>1. Positive test cases (correct data, correct output).     <br />2. Negative test cases (broken or missing data, proper handling).     <br />3. Exception test cases (exceptions are thrown and caught properly).     <br /><b>8.</b>Can you change the value of a variable while debugging a C# application?     <br /><b>Ans</b>. Yes.&#160; If you are debugging via Visual Studio.NET, just go to Immediate window. </p>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-debugging-and-testing-questions/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/interview-questions-net/net-debugging-and-testing-questions/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text=".NET Debugging and Testing Questions" data-url="http://www.ms.oyangudi.com/blog/interview-questions-net/net-debugging-and-testing-questions/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/interview-questions-net/net-debugging-and-testing-questions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

