tag:blogger.com,1999:blog-66338411894629640522024-03-13T08:37:34.812-07:00ASP.NET Tech StuffsThis blog currently contains the problems and challenges that authors of this blog have come across during their daily developments. The purpose of this blog is to share the solutions and receive suggestions from people across the world.Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.comBlogger44125tag:blogger.com,1999:blog-6633841189462964052.post-49542888917238113172011-12-26T07:39:00.000-08:002011-12-26T07:39:12.311-08:00Tuple: Return multiple values from function<div dir="ltr" style="text-align: left;" trbidi="on">
How do you return multiple values from function? <br />
<br />
Option 1: use out parameters. But this will just bloat your function signature if the list is long<br />
Option 2: Encapsulate all return values as properties of class and just return the object of that class. But what if that class is not reusable. Will you be just adding the dumb classes to increase assembly size and abusing the OOPs.<br />
<br />
Here comes the solution "Tuple" in .NET 4.<br />
<br />
By using Tuple type you can return upto 8 items at a time. These items could be value type or reference type.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-mwN7epBIssQ/TviLU-__7II/AAAAAAAAGac/6G8E1UVkZx4/s1600/Tuple2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="52" src="http://3.bp.blogspot.com/-mwN7epBIssQ/TviLU-__7II/AAAAAAAAGac/6G8E1UVkZx4/s640/Tuple2.png" width="640" /></a></div>
<br />
<br />
Actually if you use the instance approach, you can pass a tuple inside Tuple. That means you can return a tuple of any number of items.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-xehHgD6ud0k/TviKv3BxyJI/AAAAAAAAGaQ/NIHap0VgPk4/s1600/Tuple1.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="72" src="http://4.bp.blogspot.com/-xehHgD6ud0k/TviKv3BxyJI/AAAAAAAAGaQ/NIHap0VgPk4/s400/Tuple1.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
There are few points to note though<br />
1. tuple items are read only (there is no set accessor for items). That makes its items immutable.<br />
2. The items can be accessed by using "Item<n>" property. For e.g. to access 2nd item, you have to call myTuple.Item2.</n><br />
<br />
let's take an scenario where you need this kind of structure<br />
<br />
<pre style="background: white; color: black; font-family: Consolas;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">Tuple</span><<span style="color: blue;">string</span>,<span style="color: blue;">string</span>,<span style="color: blue;">string</span>,<span style="color: blue;">string</span>> GetAny4ItemsOnMyDesk()
{
<span style="color: green;">//Instance approach</span>
<span style="color: blue;">return</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">Tuple</span><<span style="color: blue;">string</span>, <span style="color: blue;">string</span>, <span style="color: blue;">string</span>, <span style="color: blue;">string</span>>(<span style="color: #a31515;">"Laptop"</span>, <span style="color: #a31515;">"Phone"</span>, <span style="color: #a31515;">"Notebook"</span>, <span style="color: #a31515;">"Pen"</span>);
<span style="color: green;">//By using static method</span>
<span style="color: green;">//return Tuple.Create("Laptop", "Phone", "Notebook", "Pen");</span>
}</pre>
<div style="background: white; color: black; font-family: Consolas;">
<br /></div>
This is clear in the above example that you will not like to create a dumb class to contain "unrelated" things. Actually Tuple stucture can be used to contain <strong>"miscellaneous but related"</strong> items. <br />
<br />
Now lets print my desk items from Main <br />
<div style="background: white; color: black; font-family: Consolas;">
<br /></div>
<pre style="background: white; color: black; font-family: Consolas;"><span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)
{
<span style="color: blue;">var</span> ItemsOnMyDesk = GetAny4ItemsOnMyDesk();
<span style="color: #2b91af;">StringBuilder</span> sb = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringBuilder</span>();
sb.Append(<span style="color: #a31515;">"Item 1: "</span> + ItemsOnMyDesk.Item1);
sb.AppendLine();
sb.Append(<span style="color: #a31515;">"Item 2: "</span> + ItemsOnMyDesk.Item2);
sb.AppendLine();
sb.Append(<span style="color: #a31515;">"Item 3: "</span> + ItemsOnMyDesk.Item3);
sb.AppendLine();
sb.Append(<span style="color: #a31515;">"Item 4: "</span> + ItemsOnMyDesk.Item4);
sb.AppendLine();
<span style="color: #2b91af;">Console</span>.WriteLine(sb.ToString());
<span style="color: #2b91af;">Console</span>.ReadLine();
}</pre>
<div style="background: white; color: black; font-family: Consolas;">
<br /></div>
This will print my 4 items on my desk.<div style="background: white; color: black; font-family: Consolas;">
<br /></div>
You can use other data structures like keyvaluepair, collection, array etc to serve same purpose. tuple is like anonymous class generated on compile time so its object resides on heap only which gives you struct kind of datastructure out of the box.<br />
Tuple type is widely used in functional language like "Haskell" and dynamic language like "Python. Since it is of finite size and immutable structure, it is faster than list and performs better than keyvaluepair struct when passed to a function (though data retrieval is faster in keyvaluepair).<br />
<div style="background: white; color: black; font-family: Consolas;">
<br /></div>
Thanks for reading. <div style="background: white; color: black; font-family: Consolas;">
<br /></div>
<div style="background: white; color: black; font-family: Consolas;">
<br /></div>
</div>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-45197503564917064452011-07-22T06:10:00.000-07:002011-07-22T06:10:26.630-07:00How to return private collection<div dir="ltr" style="text-align: left;" trbidi="on"><br />
Did you ever try returning a private array like following?<br />
<br />
<br />
<pre style="background: white; color: black; font-family: Consolas; font-size: 13;"><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">TestPrivateArrays</span>
{
<span style="color: blue;">private</span> <span style="color: blue;">string</span>[] names;
<span style="color: blue;">public</span> <span style="color: blue;">string</span>[] Names {
<span style="color: blue;">get</span>
{
<span style="color: blue;">return </span>names;
}
}</pre><pre style="background: white; color: black; font-family: Consolas; font-size: 13;">}</pre><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"></pre><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"> <span style="color: green;">//initialize collection in constructor</span>
names = <span style="color: blue;">new</span> <span style="color: blue;">string</span>[] { <span style="color: #a31515;">"Abhishek"</span>, <span style="color: #a31515;">"Tiwari"</span> };</pre></pre></pre></pre><br />
<br />
And you thought, no one from the external world can modify it? Wrong. Since client still has direct reference of each items of collection/Array, he has full liberty to modify it.<br />
<br />
<br />
<pre style="background: white; color: black; font-family: Consolas; font-size: 13;"><span style="color: #2b91af;"> TestPrivateArrays</span> tpa = <span style="color: blue;">new</span> <span style="color: #2b91af;">TestPrivateArrays</span>();
tpa.Names[0] = <span style="color: #a31515;">"Modified"</span>; <span style="color: green;">//my private array gets modified here</span></pre><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"></pre><br />
<br />
So question is whether you can stop your client modifying your array. Answer is yes, you just need to know how to return your collection items as readonly.<br />
<br />
<b>1. Return clone of Array</b><br />
<br />
<br />
<pre style="background: white; color: black; font-family: Consolas; font-size: 13;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">TestPrivateArrays</span>
{
<span style="color: blue;">private</span> <span style="color: blue;">string</span>[] names;
<span style="color: blue;">public</span> <span style="color: blue;">string</span>[] Names {
<span style="color: blue;">get</span>
{
<span style="color: blue;">return</span> (<span style="color: blue;">string</span>[])names.Clone();
}
}</pre><pre style="background: white; color: black; font-family: Consolas; font-size: 13;">}</pre><br />
<br />
You can see, even if client tries to modify the array item, he won't be able to do so. since he is actually modifying a copy of that array but whenever he tries to get the array item, he will get the original one i.e. the unmodified one.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgskpHqKMXgBh4GiMP5qO-dKZ3cChCySkaBW4yEtP56FN-50tHOx8LDiGgN2ElPcuqvHL_eyeOhdb0HUsubQ-0tWJhvIpiIuxE4yDPHqVDLWkPNHLp7Q3CBJTNmuo7s8QoATR49hCyjm-g/s1600/CPrivateArray.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="85" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgskpHqKMXgBh4GiMP5qO-dKZ3cChCySkaBW4yEtP56FN-50tHOx8LDiGgN2ElPcuqvHL_eyeOhdb0HUsubQ-0tWJhvIpiIuxE4yDPHqVDLWkPNHLp7Q3CBJTNmuo7s8QoATR49hCyjm-g/s320/CPrivateArray.JPG" width="320" /></a></div><br />
<br />
<b>2. Return readonly collection</b><br />
<b><br />
</b><br />
If you are using .NET generics for e.g. list. You can return the collection as readonly in the following manner.<br />
<br />
<br />
<pre style="background: white; color: black; font-family: Consolas; font-size: 13;"> <span style="color: blue;">private</span> <span style="color: #2b91af;">List</span><<span style="color: blue;">string</span>> listNames;
<span style="color: blue;">public</span> <span style="color: #2b91af;">IList</span><<span style="color: blue;">string</span>> ListNames
{
<span style="color: blue;">get</span>
{
<span style="color: blue;">return</span> listNames.AsReadOnly();
}
}</pre><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"></pre><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"> <span style="color: green;">//initialize collection in constructor</span>
listNames = <span style="color: blue;">new</span> <span style="color: #2b91af;">List</span><<span style="color: blue;">string</span>> { <span style="color: #a31515;">"Abhishek"</span>, <span style="color: #a31515;">"Tiwari"</span> };</pre></pre><br />
<br />
Now if user tries to modify the collection, he will get a runtime error saying that collection is readonly (see following).<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSt9mTAhcOE0ktqDAVHQpQDkr3WABG3SqVhOIw3089LV37Io6V9UL2wA6G3TQWUyuDmva679-csPwET3Xl2Sk-fBrl5fxw9I_0g6_FbutYNTQkLd0RjgoE0iAme_vh_LRWVG19PFRKEeo/s1600/CReadOnlyList.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="129" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSt9mTAhcOE0ktqDAVHQpQDkr3WABG3SqVhOIw3089LV37Io6V9UL2wA6G3TQWUyuDmva679-csPwET3Xl2Sk-fBrl5fxw9I_0g6_FbutYNTQkLd0RjgoE0iAme_vh_LRWVG19PFRKEeo/s320/CReadOnlyList.JPG" width="320" /></a></div><br />
<br />
<b>3. Use some inbuilt readonly collection</b><br />
<b><br />
</b><br />
you can find a datastructure called ReadOnlyCollection under System.Collections.ObjectModel which is strong typed and templatized. You can use that in following manner.<br />
<br />
<br />
<pre style="background: white; color: black; font-family: Consolas; font-size: 13;"> <span style="color: blue;">private</span> System.Collections.ObjectModel.<span style="color: #2b91af;">ReadOnlyCollection</span><<span style="color: blue;">string</span>> colNames;
<span style="color: blue;">public</span> System.Collections.ObjectModel.<span style="color: #2b91af;">ReadOnlyCollection</span><<span style="color: blue;">string</span>> ColNames
{
<span style="color: blue;">get</span>
{
<span style="color: blue;">return</span> colNames;
}
}</pre><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"></pre><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"> <span style="color: green;">//initialize collection in constructor</span>
colNames = <span style="color: blue;">new</span> System.Collections.ObjectModel.<span style="color: #2b91af;">ReadOnlyCollection</span><<span style="color: blue;">string</span>>(<span style="color: blue;">new</span> <span style="color: #2b91af;">List</span><<span style="color: blue;">string</span>> { <span style="color: #a31515;">"Abhishek"</span>, <span style="color: #a31515;">"Tiwari"</span> });
</pre></pre><br />
<br />
Note that if user tries to modify this collection, he will get compile time error (remember in case of list, it was runtime error because when you modify the list, it evaluates its isReadOnly property at runtime).<br />
<br />
Thanks for reading the post.</div>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-21919596696520312602011-07-21T07:26:00.000-07:002011-07-21T07:44:37.570-07:00"toString" method in JavaScript<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;">Every object in JavaScript has 'toString' method by default. This method returns the representation of that object in string format. If you have ever called alert on an object in mistake, you would have come across this message in alert box '[object, Object]'. Actually when you put alert on object itself, it is assumed that you want to see the internal representation of the object and its 'toString' method is invoked which returns the default string for any object as mentioned before.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;">So what if you want to make your object representation more meaningful or let say you want to debug your code and just put alert here and there and wants to see what your object looks like at different point of time. Here comes overriding 'toString' method. C#/VB.NET developers, remember yourself overriding toString method of base class "Object". This is exactly similar to that.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;">Let me take an example as following<o:p></o:p></span></div><br />
<br />
<pre style="background: white; color: black; font-family: Consolas; font-size: 13;"><span style="color: blue;">function</span> Employee(name, age, company) {
<span style="color: blue;">this</span>.employeeName = name;
<span style="color: blue;">this</span>.age = age;
<span style="color: blue;">this</span>.company = company;
<span style="color: blue;">this</span>.toString = <span style="color: blue;">function</span> () {
<span style="color: blue;">return</span> <span style="color: maroon;">"Employee "</span> + <span style="color: blue;">this</span>.employeeName + <span style="color: maroon;">" of age "</span> + <span style="color: blue;">this</span>.age + </pre><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"><span style="color: maroon;">" working in "</span> + <span style="color: blue;">this</span>.company;
}
}
</pre><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"></pre><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"></pre><pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black;"><span class="Apple-style-span" style="font-family: 'Times New Roman';"><span class="Apple-style-span" style="white-space: normal;"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;">What I am doing here is
basically forming a meaningful string from my Employee object properties. Now
let me put an alert on employee object.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;">
</span></div></span></span></pre><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: small; white-space: normal;">
</span></pre><pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;"><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: small; white-space: normal;"><pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black; font-family: Consolas; font-size: 13px;"> <span style="color: blue;"><</span><span style="color: maroon;">script</span> <span style="color: red;">language</span><span style="color: blue;">=</span><span style="color: blue;">"javascript"</span> <span style="color: red;">type</span><span style="color: blue;">=</span><span style="color: blue;">"text/javascript"</span><span style="color: blue;">></span>
window.onload = <span style="color: blue;">function</span> () {
<span style="color: blue;">var</span> e = <span style="color: blue;">new</span> Employee(<span style="color: maroon;">"Abhishek"</span>, <span style="color: maroon;">"30"</span>, <span style="color: maroon;">"abcSoftware"</span>);
alert(e);
}
<span style="color: blue;"><span style="color: maroon;">script</span><span style="color: blue;">></span></span></pre><pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: black; font-family: Consolas; font-size: 13px;"><span style="color: blue;">
</span></pre></span><pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: 'Times New Roman';"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;">When I run this code, on
my window onload I get following popup.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;">
</span></div></span></pre><pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: small; white-space: normal;">
</span></pre><div class="separator" style="clear: both; font-family: 'Times New Roman'; font-size: medium; text-align: center; white-space: normal;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEaYJ0RRJ0n0y7wKLEBixbHnneYebq2_nhL-0FihmDCBctGG3UsK98TgbS0pUqTtNcYKhq330e8G3qdUbZb9VDo4z0V-4l5g5YGwpR1dQUP_VZIOUy1Ty_iaDMmUq-dSDMaL45f7UvZwI/s1600/JSAlertBox.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="125" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEaYJ0RRJ0n0y7wKLEBixbHnneYebq2_nhL-0FihmDCBctGG3UsK98TgbS0pUqTtNcYKhq330e8G3qdUbZb9VDo4z0V-4l5g5YGwpR1dQUP_VZIOUy1Ty_iaDMmUq-dSDMaL45f7UvZwI/s320/JSAlertBox.JPG" width="320" /></a></div><pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: small; white-space: normal;">
</span></pre><pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: small; white-space: normal;">
</span></pre><pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: 'Times New Roman';"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;">As I said before, I can
use this method for debugging purposes or in general conveying a better
representation of my object (for e.g. if you are writing a JS library, you
would like your users to get a meaningful message while putting an alert on
your objects, won't you?)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><b style="mso-bidi-font-weight: normal;"><span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;">Note</span></b><span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;">: If you put alert on
function name itself for e.g. alert(Employee), it would be 'toString' method of <b style="mso-bidi-font-weight: normal;">function type</b> that will be called
and it will print your entire function in the alert box. Try that.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;">Thanks for reading.<o:p></o:p></span></div></span></pre></pre></div>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-52499512483739694072011-07-21T03:17:00.000-07:002011-07-21T03:33:03.840-07:00Javascript intellisense in Visual Studio 2010<div dir="ltr" style="text-align: left;" trbidi="on"><br />
Web developers always found difficult to write code when it comes to writing in any scripting language. There are many reasons contributing to it like lack of debugging features, intellisense support, no early catch on errors etc. If you know what editors like Visual Studio gives you for other contemporary strongly typed language (C#, VB.NET etc) you will find difference of an era.<br />
<br />
I am an ardent user of Visual Studio and would like to share with you that there are many good features that have been bundled with VS 2010 to support intellisense and debugging for JavaScript. If you know them all, you will surely thank Visual Studio team for making your life easy like never before.<br />
<br />
Let me explain some of the intellisense support here.<br />
<br />
<b><u>Type inference in JavaScript</u></b><br />
<b><u><br />
</u></b><br />
JavaScript is a dynamic language and does not support explicit type declarations, due to which, earlier there used to be a generic pop up showing properties for all types. VS2010 can now infer the type as soon as the assignment happens and shows only relevant properties. See the below example, it is showing the properties applicable to a number.<br />
<b><u><br />
</u></b><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEienZ1vAI0czYaLJf5_z_UdEaTnmm8xBPBs4tgN2vTPtTs7FJCfIOCMJ0Bb0Gvh81nUrQ86hWceIqcD5Cv_Ii8FCoLCrZ6pABdneeqTyX8GmvNxZCOpv_q9GeSyiEqGG4JwEqYAhZ3l0uU/s1600/JSNumber.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEienZ1vAI0czYaLJf5_z_UdEaTnmm8xBPBs4tgN2vTPtTs7FJCfIOCMJ0Bb0Gvh81nUrQ86hWceIqcD5Cv_Ii8FCoLCrZ6pABdneeqTyX8GmvNxZCOpv_q9GeSyiEqGG4JwEqYAhZ3l0uU/s1600/JSNumber.JPG" /></a></div><b><u><br />
</u></b><br />
<br />
As you know, being a loose typed language, I can change type of any variable at any time. so what if at some point of time i assign a string to my variable "num".<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg96UAgnIWfWg0nh5eEPA5yWK2DP-OOCi0J9MQJQKgXVO5fgn4QxUGdD1Z2H9HYnNmSiz2ELvrv5m42tIGQKkRixnamMN2_UiVEhNRoW5e7ktTlWh-w93DGEDTT6w_S_AoCxjYJwbtwI88/s1600/JSString.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg96UAgnIWfWg0nh5eEPA5yWK2DP-OOCi0J9MQJQKgXVO5fgn4QxUGdD1Z2H9HYnNmSiz2ELvrv5m42tIGQKkRixnamMN2_UiVEhNRoW5e7ktTlWh-w93DGEDTT6w_S_AoCxjYJwbtwI88/s1600/JSString.JPG" /></a></div><br />
You can see, now VS intellisense shows me properties only relevant to a string. Great, isn't it!!<br />
Kindly note that it does not matter that you are writing inline scripting or inside an external file. Same intellisense works beautifully at all the places.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4drkEQcWGHvMtMXLCdRaatBRa0cuPmm1TxwSxZhhH8xtvWKBsGlqUPT5J9p4j-4M0C2puj9SNNWEBU1LHsOggNkfUFbnY3VxflX2aep6RGyDaMMbJmq6DnsHToO7ZkbASM7ORoGUwNdA/s1600/JSElement.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="181" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4drkEQcWGHvMtMXLCdRaatBRa0cuPmm1TxwSxZhhH8xtvWKBsGlqUPT5J9p4j-4M0C2puj9SNNWEBU1LHsOggNkfUFbnY3VxflX2aep6RGyDaMMbJmq6DnsHToO7ZkbASM7ORoGUwNdA/s320/JSElement.JPG" width="320" /></a></div><br />
You can see above, it now shows the properties of a DOM element only.<br />
<br />
<b><u>Intellisense to Functions</u></b><br />
<b><u><br />
</u></b><br />
Why you have always been asked to decorate your methods with comments during your code review, it is not just to let others understand more about your functions right there but also to give descriptive knowledge to the consumer of your methods about how that method can be called, what purpose that method serve, information about parameters and returning object etc.<br />
By default, VS can show you the name of the function and input parameter if it is put correctly in the scope.<br />
<br />
Let say I have written a method "FOO" in my test.js<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFHcQxWeA39QybPRLP7N4O2zRCCdcV-Jk68NDYTJDunx2bMxnkM3erIHp2yv_qJB85SspAi3dK1LqvaLiEzelDyJcmLFmW0GrvBeP0fiWF_fNdlmuI1lF4faDEjQBmEzWXvhnXWDNtFT0/s1600/JSFOOImpl.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFHcQxWeA39QybPRLP7N4O2zRCCdcV-Jk68NDYTJDunx2bMxnkM3erIHp2yv_qJB85SspAi3dK1LqvaLiEzelDyJcmLFmW0GrvBeP0fiWF_fNdlmuI1lF4faDEjQBmEzWXvhnXWDNtFT0/s1600/JSFOOImpl.JPG" /></a></div>I included my test.js correctly in my aspx page and now call the method<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqb-MnFjgE1bub5GEblvlpuJpof_pXcRc55KhyphenhyphenZi-vQ_g1PuZEPkmVniaEF-w3x11LxE3Q2vahW56gAsSD9XfEXW9ZAZKzBW6lBjfq1Uwi4AXxqPdAWeGV8MXtplP2Kfi9VIhFkfkCBP8/s1600/JSCallingFOO.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="55" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqb-MnFjgE1bub5GEblvlpuJpof_pXcRc55KhyphenhyphenZi-vQ_g1PuZEPkmVniaEF-w3x11LxE3Q2vahW56gAsSD9XfEXW9ZAZKzBW6lBjfq1Uwi4AXxqPdAWeGV8MXtplP2Kfi9VIhFkfkCBP8/s320/JSCallingFOO.JPG" width="320" /></a></div>You can see, without looking at the external file, I know what parameters "foo" expects and can correctly call it.<br />
<br />
Wonder, if you could also add some intellisense hint to your method? check this now.<br />
<br />
put a summary block under your function as following. this is written exactly the same way, you write it on top of your C#,VB.NET method. so don't need to remember the template, just copy it from any of your C#/VB code page.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEFMKcVnGvy69TlpW9baprJZgwIT1IS4Ea04qs0Mb1RRLqMqP278uNpKvFDrTEZKHvUPyGIYWrrAwF2u_ymUAfCKI6wE9KfFH6Fi0RZ1ugHm_XVx5RmMhHlfNBhJR-maq30Sh6QftbuoM/s1600/JSFOOWithIntellisense.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="108" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEFMKcVnGvy69TlpW9baprJZgwIT1IS4Ea04qs0Mb1RRLqMqP278uNpKvFDrTEZKHvUPyGIYWrrAwF2u_ymUAfCKI6wE9KfFH6Fi0RZ1ugHm_XVx5RmMhHlfNBhJR-maq30Sh6QftbuoM/s320/JSFOOWithIntellisense.JPG" width="320" /></a></div><br />
and now let me call the method once again and let the magic continue<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhteOXd7KARu64r9J7RrIBSd64KpXEtDZj6XE17NULMPQ_gALUqheVy1ckDs-Qlf6TTVYL1ACU-ucqmwNnd3dnYIQciwKMjvfgCcb_I8tLzfME90BgE7rzJz9g8Sn3Yb_H-3r6ld7_Oh0Y/s1600/JSCallingFOOWithIntellisense.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="78" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhteOXd7KARu64r9J7RrIBSd64KpXEtDZj6XE17NULMPQ_gALUqheVy1ckDs-Qlf6TTVYL1ACU-ucqmwNnd3dnYIQciwKMjvfgCcb_I8tLzfME90BgE7rzJz9g8Sn3Yb_H-3r6ld7_Oh0Y/s320/JSCallingFOOWithIntellisense.JPG" width="320" /></a></div><br />
<br />
<b><u>Getting intellisense amongst external JS files</u></b><br />
<b><u><br />
</u></b><br />
Do you feel jittery when you need to call a function but don't know how to exact type it and the function is hidden somewhere under the plethora of JS files you are referring in your page (Javascript is case sensitive) or what if you want to make sure you don't write the function with the same name written elsewhere, or just for the sake of simplicity of coding you want everything under the scope (variable, functions etc) visible infront of you before writing even a single line of code as it happens when you write code in C# (you can see every public/protected/internal/private class/methods in the intellisense as per the scope).<br />
<br />
There can be many reasons, you always desired intellisense to be available not just inline but also spanning it across external files as well under the scope. Let me tell you it is fairly possible with VS 2010.<br />
<br />
Let say I created a new js file and want to reference my test.js (having function FOO, as explained above). What you need to do, just go drag your test.js into your new javascript file. VS automatically add the reference in following manner<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivr8lbCGdhwqhbiO-SdK_8eC6ZTltyrXfNj5kwq4v2QO_GH4QF0ZnJlrpA9G70Ft-BQXxJqkp_3meWwCfG5y6visktTus_s8wzcLKHUYhVLPlioIFBJ8Uw3uKzVyNvaq2aLlynUa4Cvgg/s1600/JSAddingFileRef.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivr8lbCGdhwqhbiO-SdK_8eC6ZTltyrXfNj5kwq4v2QO_GH4QF0ZnJlrpA9G70Ft-BQXxJqkp_3meWwCfG5y6visktTus_s8wzcLKHUYhVLPlioIFBJ8Uw3uKzVyNvaq2aLlynUa4Cvgg/s1600/JSAddingFileRef.JPG" /></a></div><br />
Now you have complete access to everything written in test.js to your new file. You can add as many references as you want in your new file. VS interpreter will automatically discover that file and present you the full intellisense support.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRTVAh1CxsRtiIbQG6n5Mq21U8xyNc5cf7sJW5Q2LBY4tnzL1OC4YK07pySMi1NOognIcQ3lwjnJXgGuHdNK0WSUGQIhk3cmX5QALRwH9xOCZcB8IdS1XiByYNpFoDMajiDSy6kWpN_UM/s1600/JSCallingFuncWithFileRef.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="122" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRTVAh1CxsRtiIbQG6n5Mq21U8xyNc5cf7sJW5Q2LBY4tnzL1OC4YK07pySMi1NOognIcQ3lwjnJXgGuHdNK0WSUGQIhk3cmX5QALRwH9xOCZcB8IdS1XiByYNpFoDMajiDSy6kWpN_UM/s320/JSCallingFuncWithFileRef.JPG" width="320" /></a></div><br />
<br />
<br />
<br />
Hope the article would have given you some insight on inbuilt intellisense support of JavaScript in VS. You can explore more on it and be able to write faster code with lesser number of errors.<br />
<br />
Happy coding and thanks for reading!<br />
<br />
<br />
Credit goes to Scott Gu. Reference article: <a href="http://weblogs.asp.net/scottgu/archive/2007/06/21/vs-2008-javascript-intellisense.aspx">http://weblogs.asp.net/scottgu/archive/2007/06/21/vs-2008-javascript-intellisense.aspx</a><br />
<br />
</div>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-37689390993040789022011-04-20T06:55:00.000-07:002011-04-20T08:08:10.254-07:00Beware of Constants<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 9pt;">Let say I have a third party library having code as following<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">namespace</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> Test<o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">{<o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">public</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">class</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: #2b91af; font-family: Verdana, sans-serif; font-size: 8.5pt;">TestClass</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">public</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">const</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">string</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> NAME = </span><span style="color: #a31515; font-family: Verdana, sans-serif; font-size: 8.5pt;">"Abhishek Tiwari"</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">;<o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">}<o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 9pt;">My application uses this library and prints this name on console in following manner<o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">internal</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">class</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: #2b91af; font-family: Verdana, sans-serif; font-size: 8.5pt;">Program</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">{ <o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">private</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">static</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">void</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> Main(</span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">string</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">[] args) <o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> { <o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Verdana, sans-serif; font-size: 8.5pt;"> Console</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">.WriteLine(Test.</span><span style="color: #2b91af; font-family: Verdana, sans-serif; font-size: 8.5pt;">TestClass</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">.NAME); <o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Verdana, sans-serif; font-size: 8.5pt;"> Console</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">.ReadLine(); <o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> } <o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">}<o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 9pt;">After sometime my library provider company is owned by some other company and changes the const value to something</span><span style="color: black; font-family: 'Times New Roman', serif; font-size: 13.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">public</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">const</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">string</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> NAME = </span><span style="color: #a31515; font-family: Verdana, sans-serif; font-size: 8.5pt;">"I am no more Abhishek Tiwari"</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">;</span><span style="color: black; font-family: Consolas; font-size: 8.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 9pt;">Now as being a loyal customer to that company, you get the new version of the library and replace the old version by it and now click on your executable again.<o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 9pt;">Whack!!! You still see "Abhishek Tiwari" written on the console. <o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 9pt;">So what happened in the background is mystery for you but before you bang your head here and there in confusion, let me solve this puzzle for you. <o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 9pt;">Actually when you last built your project, your compiler has put the hard-coded values in place of consts everywhere in your IL so those consts values no more refer to any part of the code whatsoever. If you look into the IL, you will find something like<o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #00b050; font-family: Verdana, sans-serif; font-size: 8.5pt;">//My IL (compiled code)</span><span style="color: #00b050; font-family: Verdana, sans-serif; font-size: 8.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">internal</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">class</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: #2b91af; font-family: Verdana, sans-serif; font-size: 8.5pt;">Program</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">{ <o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">private</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">static</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> </span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">void</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> Main(</span><span style="color: blue; font-family: Verdana, sans-serif; font-size: 8.5pt;">string</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">[] args) <o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> { <o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Verdana, sans-serif; font-size: 8.5pt;"> Console</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">.WriteLine(</span><span style="color: #a31515; font-family: Verdana, sans-serif; font-size: 8.5pt;">"Abhishek Tiwari"</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">); <o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Verdana, sans-serif; font-size: 8.5pt;"> Console</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">.ReadLine(); <o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;"> } <o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 8.5pt;">}<o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 9pt;">So even if now I have updated the third party without rebuilding my code (since it is essentially not required) my IL will remain same, and in my IL const "NAME" which was linked to third party is vanished, leaving hard coded const value behind.<o:p></o:p></span><br />
<span style="color: black; font-family: Verdana, sans-serif; font-size: 9pt;"><br />
</span><br />
<span style="color: black; font-family: Verdana, sans-serif; font-size: 9pt;">Get working code from <a href="https://docs.google.com/leaf?id=0B25WT4_yjBDJNmZhOTI5NWEtMjI0Ny00YmFkLWJlMzctODExZjc5YzcxYWQ5&hl=en">TestConst</a></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 9pt;">I hope if you are a third party provider, you will keep this in mind to avoid any shock. I am not sure what is the best possible solution for this (will keep you posted, if I come across any) but for now you can change your "const" type by "static readonly" so that your library consumer can always see the modifications.<o:p></o:p></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><i><span style="color: orange; font-family: Verdana, sans-serif; font-size: 9pt;">** Thanks to Shailendra (Author in aspnettechstuffs) for sharing this valuable information with me.</span></i><span style="color: black; font-family: Verdana, sans-serif; font-size: 9pt;"><o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><br style="mso-special-character: line-break;" /> <br style="mso-special-character: line-break;" /> </span></div><br />
</div>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-71385374185785528702011-04-19T07:02:00.000-07:002011-04-30T01:51:00.208-07:00Design By Contracts<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">Putting validations all over the places in your code is just like convoluting your code. You must have wondered sometime how good it would be if I could decorate my class with another class at runtime with all the validations. There are certainly options available with latest .NET framework for e.g. you can use injection to add behavior to your classes at runtime. You may use Unity or any other container to do so. If you are design freak, you must have understood that by all means any implementation to provide change in runtime behavior can be done by using "Decorator pattern" only. I will discuss about this in some other article but what I am going to share with you in this article is how to use <b>Code Contracts. </b><o:p></o:p></span></span></div><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"> </span><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">Code contract is something which is already present in the framework 4 under the namespace System.Diagnostic.Contracts and heavily used by .NET internal code for e.g. if you expand ICollection, IComparable etc interfaces you will find them using contracts. <o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">Unfortunately code contracts feature comes by default with Visual Studio Premium and Ultimate edition but if you are using lower version like Professional one, you can still download the external library and make a use of them.<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">Ok so enough background now let’s jump into the implementation part.<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">As I said earlier, if you are not using VS 2010 Premium or Ultimate edition, you can download the Code Contract extension from</span><span class="apple-style-span"><span style="color: black; font-size: 13.5pt;"> </span></span><span class="apple-style-span"><span style="color: black; font-family: Verdana,sans-serif; font-size: 9pt;"><a href="http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx">Code Contract Extension</a></span></span><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;"><o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">Fair enough, now I am taking a use case where I am providing user a Math divide functionality and I want to make sure that user does not divide the number by zero.<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">One way I can do it this<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">public</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">class</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">MathFunctions</span><span style="color: black; font-family: Consolas; font-size: 9pt;"><o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">public</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">double</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> Divide(</span><span style="color: blue; font-family: Consolas; font-size: 9pt;">double</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> number, </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">double</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> divider)<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">Debug</span><span style="color: black; font-family: Consolas; font-size: 9pt;">.Assert((divider == 0), </span><span style="color: #a31515; font-family: Consolas; font-size: 9pt;">"cannot divide by zero"</span><span style="color: black; font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">return</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> number / divider;<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">This will make sure that as soon as my client passes zero, he gets an exception. I can implement divide function as<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">if</span><span style="color: black; font-family: Consolas; font-size: 9pt;">(divider!=0)<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: 9pt;"> return</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> number / divider;<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">throw</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">new</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">ArgumentException</span><span style="color: black; font-family: Consolas; font-size: 9pt;">();<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">But this is essentially not part of my business logic and henceforth should not be part of my function. Now I need a way to inject the validation at runtime. Let's see how we can do the same using contracts.<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">Refer System.Diagnostics;System.Diagnostics.Contracts; namespaces in your code.<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">I now define an interface which will contain the required method signatures. I will decorate this interface with contract so that my compiler could inject the contract into all concrete implementers of my interface.<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> [System.Diagnostics.Contracts.</span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">ContractClass</span><span style="color: black; font-family: Consolas; font-size: 9pt;">(</span><span style="color: blue; font-family: Consolas; font-size: 9pt;">typeof</span><span style="color: black; font-family: Consolas; font-size: 9pt;">(</span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">ITestContractCodeContract</span><span style="color: black; font-family: Consolas; font-size: 9pt;">))]<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">public</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">interface</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">ITestContract</span><span style="color: black; font-family: Consolas; font-size: 9pt;"><o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">double</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> Divide(</span><span style="color: blue; font-family: Consolas; font-size: 9pt;">double</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> number, </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">double</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> divider);<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">You see I am telling compiler that my interface carries a contract which is explicitly implemented in class ITestContractCodecontract. Now time to write the contract class.<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;">[System.Diagnostics.Contracts.</span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">ContractClassFor</span><span style="color: black; font-family: Consolas; font-size: 9pt;">(</span><span style="color: blue; font-family: Consolas; font-size: 9pt;">typeof</span><span style="color: black; font-family: Consolas; font-size: 9pt;">(</span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">ITestContract</span><span style="color: black; font-family: Consolas; font-size: 9pt;">))]<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">public</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">class</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">ITestContractCodeContract</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> : </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">ITestContract</span><span style="color: black; font-family: Consolas; font-size: 9pt;"><o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">public</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">double</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> Divide(</span><span style="color: blue; font-family: Consolas; font-size: 9pt;">double</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> number, </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">double</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> divider)<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">Contract</span><span style="color: black; font-family: Consolas; font-size: 9pt;">.Requires<</span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">ArgumentException</span><span style="color: black; font-family: Consolas; font-size: 9pt;">>((divider > 0.0), </span><span style="color: #a31515; font-family: Consolas; font-size: 9pt;">"You cannot divide by zero"</span><span style="color: black; font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">Contract</span><span style="color: black; font-family: Consolas; font-size: 9pt;">.Ensures((number != 1), </span><span style="color: #a31515; font-family: Consolas; font-size: 9pt;">"abc"</span><span style="color: black; font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">return</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">default</span><span style="color: black; font-family: Consolas; font-size: 9pt;">(</span><span style="color: blue; font-family: Consolas; font-size: 9pt;">double</span><span style="color: black; font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">Again I am decorating this class to tell compiler that this class carries contract for my interface. There are many methods which you would like to look in Contract class (see my references below) but since mostly you would like to write some precondition and postcondition, I am using Requires and Ensures methods of Contract class in my example. Requires provide you a precondition and Ensures provide you a postcondition contract.<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">Now what my contract class means to runtime, it says that any class implementing my</span><span style="color: black; font-family: 'Times New Roman',serif; font-size: 13.5pt;"> </span><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">interface divide function if and when called, should first validate (before going into divide function implementation) that divider is not zero and if contract is not broken it should run through the concrete implementation of divide and as soon as it comes out of that function it should make sure my postcondition contract (number not equal to 1) is not breaking.<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">let me write one concrete implementation of my interface<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: 9pt;">public</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">class</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">ActualTestContract</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> : </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">ITestContract</span><span style="color: black; font-family: Consolas; font-size: 9pt;"><o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> <o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">public</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">double</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> Divide(</span><span style="color: blue; font-family: Consolas; font-size: 9pt;">double</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> number, </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">double</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> divider)<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> //</span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">Debug</span><span style="color: black; font-family: Consolas; font-size: 9pt;">.Assert((divider == 0), </span><span style="color: #a31515; font-family: Consolas; font-size: 9pt;">"cannot divide by zero"</span><span style="color: black; font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">if</span><span style="color: black; font-family: Consolas; font-size: 9pt;">(divider!=0)<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">return</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> number / divider;<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">throw</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">new</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">ArgumentException</span><span style="color: black; font-family: Consolas; font-size: 9pt;">();<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">Now let me call my concrete class and check what happens<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: 9pt;">internal</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">class</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">Program</span><span style="color: black; font-family: Consolas; font-size: 9pt;"><o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">private</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">static</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">void</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> Main()<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">ITestContract</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> test = </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">new</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">ActualTestContract</span><span style="color: black; font-family: Consolas; font-size: 9pt;">();<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">double</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> division = test.Divide(1, 0);<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">Console</span><span style="color: black; font-family: Consolas; font-size: 9pt;">.WriteLine(</span><span style="color: #a31515; font-family: Consolas; font-size: 9pt;">"division value is "</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> + division);<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">Console</span><span style="color: black; font-family: Consolas; font-size: 9pt;">.Read();<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">You see my call actually breaks both pre and post condition but so far if you are copying the above mentioned code in a project and trying to run, you won't get any exception. Actually there is a config setting in your Project -> Properties ->Code contract tab (you will get it only if you have installed the extension) -> check runtime contract checking<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">If you do so, you will get assertions for both pre and post condition. Please note that if you are using VS2010 premium or ultimate edition, you will get these assertions failing on compile time, since it uses static code analyzer which is able to look into your code contract implementation and evaluate it on compile time it would be able to catch exceptions like NullReference, ArgumetOutOfRange etc.<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">There might be a case when you want some validations to be applied to your class level. You can do so by writing a method in your class and putting an attribute "ContractInVariantMethod" for e.g.<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> [</span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">ContractInvariantMethod</span><span style="color: black; font-family: Consolas; font-size: 9pt;">]<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">private</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">void</span><span style="color: black; font-family: Consolas; font-size: 9pt;"> ObjectInvariant()<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9pt;">Contract</span><span style="color: black; font-family: Consolas; font-size: 9pt;">.Invariant((</span><span style="color: blue; font-family: Consolas; font-size: 9pt;">this</span><span style="color: black; font-family: Consolas; font-size: 9pt;">.definition != </span><span style="color: blue; font-family: Consolas; font-size: 9pt;">string</span><span style="color: black; font-family: Consolas; font-size: 9pt;">.Empty), </span><span style="color: #a31515; font-family: Consolas; font-size: 9pt;">"You have to have definition properly defined in the class"</span><span style="color: black; font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></span></div><div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">The code will be evaluated as soon as instance of this class is visible to any client. It says that no matter what, my instance cannot have empty definition (assume definition is a property inside my class). <o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">If you want to understand more of Contracts Refer following links<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span class="apple-style-span"><span style="color: black; font-family: Verdana,sans-serif; font-size: 9pt;"><a href="http://msdn.microsoft.com/en-us/library/dd264808.aspx">MSDN article on code contracts</a></span><o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">I am attaching herewith my implementation code for you to debug and get a real feel of Code contracts.<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span class="apple-style-span"><span style="color: black; font-family: Verdana,sans-serif; font-size: 9pt;"><a href="https://docs.google.com/leaf?id=0B25WT4_yjBDJNjYzOWYxNTAtZGFhYi00M2I5LWE4MjktNDQ3NmE5OWVkOTgw&hl=en">TestContract Project</a></span><o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">Hope this article has helped you understanding the power of decoration and how you can keep your code clean by separating out the aspects (validation, logging, exceptions etc).<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><span style="color: black; font-family: Verdana,sans-serif; font-size: 10pt;">Thanks for reading..<o:p></o:p></span></span></div><div class="MsoNormal"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2faspnettechstuffs.blogspot.com%2f2011%2f04%2fdesign-by-contracts.html"><img alt="kick it on DotNetKicks.com" border="0" src="http%3A%2F%2Fwww.dotnetkicks.com%2FServices%2FImages%2FKickItImageGenerator.ashx%3Furl%3Dhttp%253a%252f%252faspnettechstuffs.blogspot.com%252f2011%252f04%252fdesign-by-contracts.html" /></a><br />
</span><br />
<div class="MsoNormal"><span class="Apple-style-span" style="font-family: Verdana,sans-serif; font-size: x-small;"><br />
</span></div></div>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-47620821932724054292011-04-14T02:42:00.000-07:002011-07-25T02:45:29.882-07:00Anonymous method exposed<div dir="ltr" style="text-align: left;" trbidi="on"><span class="Apple-style-span" style="line-height: 18px;">In this post, I am going to explain what Anonymous function is and how CLR interprets them.</span><br />
<div class="MsoNormal"><span style="line-height: 115%;">Anonymous functions were introduced in .NET 2.0. They provide you the in place code block where a delegate object is acceptable. Anonymous method can reduce the overhead of declaring a function and you can declare them right at the point of the invocation.<o:p></o:p></span></div><pre><span style="color: blue; font-family: Consolas;">
</span></pre><pre><span class="Apple-style-span" style="color: blue; font-family: Consolas;"><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">AnonymousFunction</span>
{
<span style="color: blue;">public</span> <span style="color: blue;">delegate</span> <span style="color: blue;">void</span> <span style="color: #2b91af;">delFunc</span>();
<span style="color: blue;">public</span> <span style="color: blue;">void</span> Test()
{
<span style="color: blue;">int</span> i = 4;
<span style="color: #2b91af;">delFunc</span> delFunc = <span style="color: blue;">delegate</span>
{
i += 1;
<span style="color: blue;">int</span> j = 0;
<span style="color: blue;">if</span> (i > 1)
{
<span style="color: #2b91af;">Action</span><<span style="color: blue;">int</span>> del = <span style="color: blue;">delegate</span> { j += 1; i += 1; };
del(8);
}
<span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"i: "</span> + i.ToString() + <span style="color: #a31515;">" j: "</span> + j.ToString());
};
delFunc();
}
}</pre></span></pre><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="line-height: 115%;">You can see in the code above that we have used anonymous methods to give implementation to our delegates delFunc and del. The key point to note here is the variable scope within the anonymous method block. An anonymous method has all the variables available to it that your code can access at the point where anonymous method is declared. This makes it anonymous method even more useful but on the other hand writing anonymous methods all the places can make your code unmanageable as well. <o:p></o:p></span></div><div class="MsoNormal"><span style="line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="line-height: 115%;">Now the question comes, how compiler interprets them. For compiler any method should have an associated type so it has to be either instance method or static one. Compiler checks what all resources your anonymous method is using and based on take the decision how it needs to be implemented in your MSIL. <o:p></o:p></span></div><div class="MsoNormal"><span style="line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="line-height: 115%;">Compiler essentially creates a private class for each anonymous method and makes all variables used inside your anonymous method as the member variable of that private class and sets those member variables from outside (invocation point) with the value of same variables declared in the main class.<o:p></o:p></span></div><div class="MsoNormal"><span style="line-height: 115%;"><br />
</span></div><div class="MsoNormal"><span style="line-height: 115%;">To get more understanding of it, let’s see what intermediate code compiler will emit for the above mentioned code. I am simplifying the actual compiler code here for your better understanding <o:p></o:p></span></div><div class="MsoNormal"><span class="Apple-style-span" style="line-height: 18px;"></span></div><pre style="font-family: consolas;"><span style="color: blue;">
</span></pre><pre style="font-family: consolas;"><span class="Apple-style-span" style="color: blue;"><pre style="background: white; color: black; font-family: Consolas; font-size: 13;"><span style="color: blue;">private</span> <span style="color: blue;">sealed</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">MyClassForDelFuncAnonymousMethod</span>
{
<span style="color: green;">// Fields</span>
<span style="color: blue;">public</span> <span style="color: blue;">int</span> i;
<span style="color: green;">// Methods</span>
<span style="color: blue;">public</span> <span style="color: blue;">void</span> MYDelFuncAnonymousMethod()
{
<span style="color: blue;">this</span>.i++;
<span style="color: blue;">int</span> j = 0;
<span style="color: blue;">if</span> (<span style="color: blue;">this</span>.i > 1)
{
<span style="color: #2b91af;">MyClassForDelAnonymousMethod</span> oMyClassForDelAnonymousMethod = <span style="color: blue;">new</span> <span style="color: #2b91af;">MyClassForDelAnonymousMethod</span>();
oMyClassForDelAnonymousMethod.j = j;
oMyClassForDelAnonymousMethod.oMyClassForDelFuncAnonymousMethod = <span style="color: blue;">this</span>;
<span style="color: #2b91af;">Action</span><<span style="color: blue;">int</span>> del= oMyClassForDelAnonymousMethod.MYDelAnonymousMethod(8);
}
<span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"i: "</span> + <span style="color: blue;">this</span>.i.ToString() + <span style="color: #a31515;">" j: "</span> + j.ToString());
}
<span style="color: green;">// Nested Types</span>
<span style="color: blue;">private</span> <span style="color: blue;">sealed</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">MyClassForDelAnonymousMethod</span>
{
<span style="color: green;">// Fields</span>
<span style="color: blue;">public</span> AnonymousFunction.MyClassForDelFuncAnonymousMethod oMyClassForDelFuncAnonymousMethod;
<span style="color: blue;">public</span> <span style="color: blue;">int</span> j;
<span style="color: green;">// Methods</span>
<span style="color: blue;">public</span> <span style="color: blue;">void</span> MYDelAnonymousMethod (<span style="color: blue;">int</span>)
{
<span style="color: blue;">this</span>.j++;
<span style="color: blue;">this</span>.oMyClassForDelFuncAnonymousMethod.i++;
}
}
}
<span style="color: blue;">public</span> <span style="color: blue;">void</span> Test()
{
<span style="color: blue;">int</span> i = 4;
MyClassForDelFuncAnonymousMethod oMyClassForDelFuncAnonymousMethod = <span style="color: blue;">new</span> MyClassForDelFuncAnonymousMethod();
oMyClassForDelFuncAnonymousMethod.i = i;
i++;
k++;
AnonymousFunction.delFunc delFunc = <span style="color: blue;">new</span> AnonymousFunction.delFunc(oMyClassForDelFuncAnonymousMethod.MYDelFuncAnonymousMethod)
}
</pre></span></pre><div class="MsoNormal"><br />
</div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span class="apple-style-span"><span style="color: black; font-family: 'Trebuchet MS', sans-serif; font-size: 11.5pt; line-height: 115%;"><o:p></o:p></span></span></div></div>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-87153593449347706192011-04-13T00:58:00.000-07:002011-04-13T04:35:55.615-07:00Typeof vs GetType (how to compare types)<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div class="MsoNormal"><span class="Apple-style-span" style="line-height: 18px;"></span></div><div class="MsoNormal"></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><br />
</span><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">Let say I have implemented few classes in following manner<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Public</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Interface</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">IA</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Property</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">Id</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">As</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">String</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">End</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Interface</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Public</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Class</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">A</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Private</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">_id</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">As</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Integer</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Public</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Overridable</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Property</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">Id</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">As</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Integer</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Get</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Return</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">_id</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">End</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Get</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Set</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">(</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">ByVal</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">value</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">As</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Integer</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">)</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> _id = value</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">End</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Set</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">End</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Property</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">End</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Class</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Public</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Class</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">B</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Inherits</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">A</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Implements</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">IA</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Public</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Property</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">Id</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">As</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">String</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Implements</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">IA</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">.Id</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Get</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">End</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Get</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Set</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">(</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">ByVal</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">value</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">As</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">String</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">)</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">End</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Set</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">End</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Property</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">End</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Class</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 13.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">Now I write switch statement to compare type like these ways<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Dim</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">a</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">As</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">IA</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">=</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">New</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">B</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> a.Id =</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">"2"</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Dim</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">b</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">As</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">A</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;">=</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">New</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">B</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> b.Id =</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">"2"</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Dim</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">t</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">As</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">String</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">= a.GetType.ToString</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Select</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Case</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">t</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Case</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">GetType</span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">(</span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: #2b91af; font-family: Consolas; font-size: 9.5pt;">A</span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">).ToString</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: #2b91af; font-family: Consolas; font-size: 9.5pt;">Console</span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">.WriteLine(</span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: #a31515; font-family: Consolas; font-size: 9.5pt;">"type is a"</span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">)</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Case</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">GetType</span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">(</span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: #2b91af; font-family: Consolas; font-size: 9.5pt;">B</span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">).ToString</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: #2b91af; font-family: Consolas; font-size: 9.5pt;">Console</span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">.WriteLine(</span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: #a31515; font-family: Consolas; font-size: 9.5pt;">"type is b"</span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">)</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">End</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Select</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Select</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Case</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">True</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Case</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">TypeOf</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">a</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Is</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: #2b91af; font-family: Consolas; font-size: 9.5pt;">A</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: #2b91af; font-family: Consolas; font-size: 9.5pt;">Console</span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">.WriteLine(</span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: #a31515; font-family: Consolas; font-size: 9.5pt;">"type is a"</span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">)</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Case</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">TypeOf</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">a</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Is</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: #2b91af; font-family: Consolas; font-size: 9.5pt;">B</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: #2b91af; font-family: Consolas; font-size: 9.5pt;">Console</span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">.WriteLine(</span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: #a31515; font-family: Consolas; font-size: 9.5pt;">"type is b"</span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">)</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">End</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Select</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Select</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Case</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">True</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Case</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">TypeOf</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">b</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Is</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: #2b91af; font-family: Consolas; font-size: 9.5pt;">A</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: #2b91af; font-family: Consolas; font-size: 9.5pt;">Console</span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">.WriteLine(</span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: #a31515; font-family: Consolas; font-size: 9.5pt;">"type is a"</span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">)</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Case</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">TypeOf</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">b</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Is</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: #2b91af; font-family: Consolas; font-size: 9.5pt;">B</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: #2b91af; font-family: Consolas; font-size: 9.5pt;">Console</span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">.WriteLine(</span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: #a31515; font-family: Consolas; font-size: 9.5pt;">"type is b"</span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;">)</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">End</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: lime; background-image: initial; background-origin: initial; color: blue; font-family: Consolas; font-size: 9.5pt;">Select</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">Now note that the yellow one will print “type is b” but green one will print “type is a”. actually "is" operator traverses the complete hierarchy to match the type so typeof a is “IA”,”A”,”B” all true. But GetType does not return you the type of reference instead actual type since it is calculated on runtime so it will just give you a.GetType = B only.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">Now let me share with you some interesting methods from System.Type namespace which works ofcourse on runtime and can be very handy.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">Let me first define some dummy interfaces, classes and their relations.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10pt;"> </span><span style="color: blue; font-family: Consolas; font-size: 10pt;">interface</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">IBase</span><span style="color: black; font-family: Consolas; font-size: 10pt;"><br />
{<br />
<br />
}<br />
</span><span style="color: blue; font-family: Consolas; font-size: 10pt;">interface</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">IA</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> : </span><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">IBase</span><span style="color: black; font-family: Consolas; font-size: 10pt;"><br />
{<br />
<br />
}<br />
<br />
</span><span style="color: blue; font-family: Consolas; font-size: 10pt;">class</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">A</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> : </span><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">IA</span><span style="color: black; font-family: Consolas; font-size: 10pt;"><br />
{<br />
<br />
}<br />
<br />
</span><span style="color: blue; font-family: Consolas; font-size: 10pt;">class</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">B</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> : </span><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">A</span><span style="color: black; font-family: Consolas; font-size: 10pt;"><br />
{<br />
<br />
}<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">Now let me create few objects out of that</span><span style="color: black; font-family: Consolas; font-size: 10pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">IBase</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> ibase = </span><span style="color: blue; font-family: Consolas; font-size: 10pt;">new</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">B</span><span style="color: black; font-family: Consolas; font-size: 10pt;">();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">IA</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> ia = </span><span style="color: blue; font-family: Consolas; font-size: 10pt;">new</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">B</span><span style="color: black; font-family: Consolas; font-size: 10pt;">();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">A</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> a = </span><span style="color: blue; font-family: Consolas; font-size: 10pt;">new</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">A</span><span style="color: black; font-family: Consolas; font-size: 10pt;">();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">B</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> b = </span><span style="color: blue; font-family: Consolas; font-size: 10pt;">new</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">B</span><span style="color: black; font-family: Consolas; font-size: 10pt;">();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">Now I want to see if type of my object b is derived from type of my object a. There are two methods<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">1. Type.IsAssignableFrom<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">2. Type.IsSubclassOf<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;"> // x.IsAssignableFrom(y) returns true if:<br />
// (1) x and y are the same type<br />
// (2) x and y are in the same inheritance hierarchy<br />
// (3) y is implemented by x<br />
// (4) y is a generic type parameter and one of its constraints is x<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">IsSubclassOf function does just reverse of IsAssignableFrom. So if (typeof)x.IsAssignableFrom(typeof(y)) is true then (typeof)y.IsSubclassOf(typeof)x) will also be true.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">Kindly note that the above two functions are valid on concrete types only. I will explain how to get types for interface in a minute, hang on.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">let's get some working examples (refer above mentioned classes and objects)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">1. ia.GetType().IsAssignableFrom(a.GetType()) will return false since actual type of ia is "B".<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">2. a.GetType().IsAssignableFrom(ia.GetType()) will return true since object of type of ia ("B") can be assigned to type of a ("A")<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">3. b.GetType().IsAssignableFrom(a.GetType()) will return false since b is not assignable from a type<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">Now some examples of IsSubclassOf<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">1. a.GetType().IsSubclassOf(ia.GetType()) will return false since ia (type "B") is not base class of a (type "A").<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">2. b.GetType().IsSubclassOf(a.GetType()) will return true since "B" is subclass of "A".<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">Let's discuss about checking the interface type now<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">If I want to see how many interfaces are implemented by the type of my object we can use GetInterfaces method<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">Type</span><span style="color: black; font-family: Consolas; font-size: 10pt;">[] types = ia.GetType().GetInterfaces();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">will give me types[0] = "IBase" and types[1] = "IA"<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">If I want to see whether a particular type is implemented by my object type, I can use GetInterface method and pass interface name as string parameter.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">Type</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> type = ia.GetType().GetInterface(</span><span style="color: #a31515; font-family: Consolas; font-size: 10pt;">"IA"</span><span style="color: black; font-family: Consolas; font-size: 10pt;">);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">will return me IA (interface type) since type of ia ("B") implements it.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">similarly</span><span style="color: black; font-family: Consolas; font-size: 13.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">Type</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> type = b.GetType().GetInterface(</span><span style="color: #a31515; font-family: Consolas; font-size: 10pt;">"IBase"</span><span style="color: black; font-family: Consolas; font-size: 10pt;">);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">will also return me IBase type since my object b has that in its hierarchy.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="color: black; font-family: Verdana, sans-serif; font-size: 10pt;">Now what if I do something like<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 10pt;">Type</span><span style="color: black; font-family: Consolas; font-size: 10pt;"> type = ia.GetType().GetInterface(</span><span style="color: #a31515; font-family: Consolas; font-size: 10pt;">"I"</span><span style="color: black; font-family: Consolas; font-size: 10pt;">);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span style="font-family: Verdana, sans-serif; font-size: 10pt;">where I is some unrelated interface. you might have guessed it correctly type object will be null and we can tell that my object type never has interface "I" type in its complete hierarchy.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><br />
<br />
<div class="MsoNormal"><o:p></o:p></div><br />
<div class="MsoNormal"></div></div>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com3tag:blogger.com,1999:blog-6633841189462964052.post-61572575205185474972011-04-11T06:27:00.000-07:002011-04-27T06:31:02.873-07:00Covariance vs Contravariance<div dir="ltr" style="text-align: left;" trbidi="on"><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>EN-US</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>HE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:DontVertAlignCellWithSp/> <w:DontBreakConstrainedForcedTables/> <w:DontVertAlignInTxbx/> <w:Word11KerningPairs/> <w:CachedColBalance/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="--"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/> <m:defJc m:val="centerGroup"/> <m:wrapIndent m:val="1440"/> <m:intLim m:val="subSup"/> <m:naryLim m:val="undOvr"/> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/> <w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/> <w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/> <w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/> <w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/> <w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/> <w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/> <w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/> <w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/> <w:LsdException Locked="false" Priority="37" Name="Bibliography"/> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin-top:0in;
mso-para-margin-right:0in;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0in;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-language:AR-SA;}
</style> <![endif]--> <div class="MsoNormalCxSpFirst" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Variance is actually nothing new in .NET but .NET 4 has extensively used them in its framework and that makes it essential to understand. Variance actually provides you the implicit conversion (instead of explicit typecasting everywhere). </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Covariance happens when you assign something more derived in the hierarchy to less derived so that assignment compatibility is preserved for e.g. </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: green; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">//Example of Covariance</span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: green; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">//String (more derived type) is direcly assignable to Object(less derived type></span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">IEnumerable</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">string</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">> stringCollection = </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">new</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">List</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">string</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">>();</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">IEnumerable</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">object</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">> objectCollection = stringCollection;</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Or </span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">IEnumerable</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">object</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">> obj = </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">new</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">List</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">string</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">>();</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Contravariance is just opposite to Covariance and happens when you assign something less derived in the hierarchy to more derived type such that assignment compatibility is reversed for e.g.</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">//Example of Contravariance</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">//More derived type delegate is assignable to delegate containing less derived type</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-layout-grid-align: none; text-autospace: none;"><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Action</span><span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><<span style="color: blue;">object</span>> o = WriteToConsole;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-layout-grid-align: none; text-autospace: none;"><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Action</span><span style="font-family: Consolas; font-size: 9.5pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><<span style="color: blue;">string</span>> o1 = o;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">public</span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> WriteToConsole(<span style="color: blue;">object</span> o){} </span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">So the question comes where they are actually supported in framework</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; text-indent: -.25in;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">1.</span><span style="font-family: "; font-size: 7.0pt;"> </span><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Covariance in arrays (since C# 1.0) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; text-indent: -.25in;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">2.</span><span style="font-family: "; font-size: 7.0pt;"> </span><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Covariance and Contravariance in delegates, also known as “method group variance” (since C# 2.0) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; text-indent: -.25in;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">3.</span><span style="font-family: "; font-size: 7.0pt;"> </span><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Variance for generic type parameters in interfaces and delegates (since C# 4.0) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Let’s learn examples for each of them</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Covariance in Arrays:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">class</span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Program</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">//Covariance in array</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">//I can directly assign more derived type to its one of the base types in hierarchy</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">object</span>[] obj = <span style="color: blue;">new</span> <span style="color: blue;">string</span>[10];</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> obj[0] = <span style="color: #a31515;">"Abhishek"</span>;</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Console</span>.WriteLine(obj[0]);</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">//Not 100% safe, check following line which will compile but throw runtime exception</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">//Exception: ArrayTypeMismatchException</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> obj[1] = <span style="color: blue;">new</span> <span style="color: blue;">object</span>();</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Console</span>.Read();</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Covariance and Contravariance in Delegates:</span></b><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">class</span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Program</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">//Covariance in delegate</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Func</span><<span style="color: blue;">object</span>> myFuncExForCovariance = GetMyName;</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Console</span>.WriteLine(myFuncExForCovariance());</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">//Contravariance in delegate</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Action</span><<span style="color: blue;">string</span>> myActionExForContravariance = PrintMyName;</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> myActionExForContravariance(<span style="color: #a31515;">"Abhishek"</span>);</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Console</span>.Read();</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">static</span> <span style="color: #2b91af;">String</span> GetMyName()</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">return</span> <span style="color: #a31515;">"Abhishek"</span>;</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> PrintMyName(<span style="color: blue;">object</span> s)</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Console</span>.WriteLine(s);</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Does this look scary? How to find when it is supporting covariance or Contravariance? Actually .Net 4 provides you syntax for that. If type is “out” it means it is Contravariance and you can assign less derived type. If type is “in” it means it is covariance and you can assign more derived type. So if you look at the metadata of the delegates used above, you would be able to understand it clearly</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">// Type parameters:</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">// T:</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">// The type of the parameter of the method that this delegate encapsulates.This</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">// type parameter is contravariant. That is, you can use either the type you</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">// specified or any type that is less derived. For more information about covariance</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">// and contravariance, see Covariance and Contravariance in Generics.</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span lang="FR" style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-ansi-language: FR; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">public</span><span lang="FR" style="font-family: Consolas; font-size: 10.0pt; mso-ansi-language: FR; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">delegate</span> <span style="color: blue;">void</span> <span style="color: #2b91af;">Action</span><<span style="color: blue;">in</span> T>(T obj);</span><span lang="FR" style="font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: FR; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: green; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">// Type parameters:</span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">// TResult:</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">// The type of the return value of the method that this delegate encapsulates.This</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">// type parameter is covariant. That is, you can use either the type you specified</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">// or any type that is more derived. For more information about covariance and</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">// contravariance, see Covariance and Contravariance in Generics.</span></span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">public</span> <span style="color: blue;">delegate</span> TResult <span style="color: #2b91af;">Func</span><<span style="color: blue;">out</span> TResult>();</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Infact you can write your own delegates and interfaces using the same syntax of variance. </span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">class</span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Program</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">public</span> <span style="color: blue;">delegate</span> TResult <span style="color: #2b91af;">MyCustomDelegate</span><<span style="color: blue;">in</span> Tin1, <span style="color: blue;">in</span> Tin2, <span style="color: blue;">out</span> TResult>(Tin1 input1, Tin2 input2);</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">MyCustomDelegate</span><<span style="color: #2b91af;">Dog</span>, <span style="color: #2b91af;">Dog</span>, <span style="color: blue;">object</span>> mydel = TestMyDelegateWithVariance;</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Console</span>.WriteLine(mydel(<span style="color: blue;">new</span> <span style="color: #2b91af;">Dog</span>(), <span style="color: blue;">new</span> <span style="color: #2b91af;">Dog</span>()));</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Console</span>.Read();</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">string</span> TestMyDelegateWithVariance(<span style="color: #2b91af;">Animal</span> i, <span style="color: #2b91af;">Animal</span> j)</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">return</span> (i.legs + j.legs).ToString();</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">class</span> <span style="color: #2b91af;">Animal</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><span style="mso-spacerun: yes;"> </span> <span style="color: blue;">public</span> <span style="color: blue;">int</span> legs { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">public</span> Animal()</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> legs = 2;</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">class</span> <span style="color: #2b91af;">Dog</span> : <span style="color: #2b91af;">Animal</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">public</span> Dog()</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> legs = 4;</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">This will print 4 + 4 = 8 as expected.</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">The point to note is that covariance and Contravariance is meant for reference types only, the concept is not applicable on value types.</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: green; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">//will run fine</span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">IEnumerable</span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><<span style="color: blue;">object</span>> oRefToRef = <span style="color: blue;">new</span> <span style="color: #2b91af;">List</span><<span style="color: #2b91af;">String</span>>();</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: green; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">//will throw a compile time error, need explicit typecasting</span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">IEnumerable</span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><<span style="color: blue;">object</span>> o = <span style="color: blue;">new</span> <span style="color: #2b91af;">List</span><<span style="color: blue;">int</span>>();</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Variance on generic interfaces:</span></b><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">class</span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Program</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">//The following conversion will work fine due to variance</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">ITestVariance</span><<span style="color: #2b91af;">Dog</span>, <span style="color: #2b91af;">Animal</span>> myTestVariance = <span style="color: blue;">new</span> <span style="color: #2b91af;">ConcreteTestVariance</span><<span style="color: #2b91af;">Animal</span>, <span style="color: #2b91af;">Dog</span>>();</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">//Following will demand for explicit conversion since wrong usage of variance constraint</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">ITestVariance</span><<span style="color: #2b91af;">Dog</span>, <span style="color: #2b91af;">Animal</span>> myTestVariance = <span style="color: blue;">new</span> <span style="color: #2b91af;">ConcreteTestVariance</span><<span style="color: #2b91af;">PamellianDog</span>, <span style="color: #2b91af;">Animal</span>>();</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Console</span>.Read();</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">interface</span> <span style="color: #2b91af;">ITestVariance</span><<span style="color: blue;">in</span> T, <span style="color: blue;">out</span> T1></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">//following interface is invariant in nature since it does not specify</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">//in/out paramater</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">interface</span> <span style="color: #2b91af;">ITestInVariance</span><t, t1> : <span style="color: #2b91af;">ITestVariance</span><t, t1></t, t1></t, t1></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">//following interface is variant in nature </span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span lang="FR" style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-ansi-language: FR; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">interface</span><span lang="FR" style="font-family: Consolas; font-size: 10.0pt; mso-ansi-language: FR; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">IDerTestVariance</span><<span style="color: blue;">in</span> T, <span style="color: blue;">out</span> T1> : <span style="color: #2b91af;">ITestVariance</span><t, t1></t, t1></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span lang="FR" style="font-family: Consolas; font-size: 10.0pt; mso-ansi-language: FR; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">{</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">//classes and structs are always invariant (remember only delegates and interfaces</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: green;">//of generic types can support variance)</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span lang="FR" style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-ansi-language: FR; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">class</span><span lang="FR" style="font-family: Consolas; font-size: 10.0pt; mso-ansi-language: FR; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">ConcreteTestVariance</span><t, t1> : <span style="color: #2b91af;">ITestVariance</span><t, t1> <span style="color: blue;">where</span> T1 : T</t, t1></t, t1></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span lang="FR" style="font-family: Consolas; font-size: 10.0pt; mso-ansi-language: FR; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">{</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">class</span> <span style="color: #2b91af;">Animal</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">public</span> <span style="color: blue;">int</span> legs { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">public</span> Animal()</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> legs = 2;</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">class</span> <span style="color: #2b91af;">Dog</span> : <span style="color: #2b91af;">Animal</span></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">public</span> Dog()</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> legs = 4;</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span lang="FR" style="font-family: Consolas; font-size: 10.0pt; mso-ansi-language: FR; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">class</span> <span style="color: #2b91af;">PamellianDog</span> : <span style="color: #2b91af;">Dog</span> { }</span><span lang="FR" style="font-family: "Courier New"; font-size: 10.0pt; mso-ansi-language: FR; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">The following interfaces from framework already support variance</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><ul style="margin-top: 0in;" type="disc"><li class="MsoNormalCxSpMiddle" style="color: black; line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo1; tab-stops: list .5in;"><b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><a href="http://msdn.microsoft.com/en-us/library/9eekhta0%28VS.100%29.aspx"><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">IEnumerable</span></a></span></b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> (T is covariant) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></li>
<li class="MsoNormalCxSpMiddle" style="color: black; line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo1; tab-stops: list .5in;"><b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><a href="http://msdn.microsoft.com/en-us/library/78dfe2yb%28VS.100%29.aspx"><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">IEnumerator</span></a></span></b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> (T is covariant) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></li>
<li class="MsoNormalCxSpMiddle" style="color: black; line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo1; tab-stops: list .5in;"><b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><a href="http://msdn.microsoft.com/en-us/library/bb351562%28VS.100%29.aspx"><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">IQueryable</span></a></span></b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> (T is covariant) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></li>
<li class="MsoNormalCxSpMiddle" style="color: black; line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo1; tab-stops: list .5in;"><b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><a href="http://msdn.microsoft.com/en-us/library/bb344977%28VS.100%29.aspx"><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">IGrouping</span></a></span></b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> (TKey and TElement are covariant) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></li>
<li class="MsoNormalCxSpMiddle" style="color: black; line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo1; tab-stops: list .5in;"><b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><a href="http://msdn.microsoft.com/en-us/library/8ehhxeaf%28VS.100%29.aspx"><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">IComparer</span></a></span></b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> (T is contravariant) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></li>
<li class="MsoNormalCxSpMiddle" style="color: black; line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo1; tab-stops: list .5in;"><b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><a href="http://msdn.microsoft.com/en-us/library/ms132151%28VS.100%29.aspx"><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">IEqualityComparer</span></a></span></b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> (T is contravariant) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></li>
<li class="MsoNormalCxSpMiddle" style="color: black; line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo1; tab-stops: list .5in;"><b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><a href="http://msdn.microsoft.com/en-us/library/4d7sx9hd%28VS.100%29.aspx"><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">IComparable</span></a></span></b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> (T is contravariant) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></li>
</ul><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">The following delegates from framework has inbuilt variance support</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><br />
</div><ul style="margin-top: 0in;" type="disc"><li class="MsoNormalCxSpMiddle" style="color: black; line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo2; tab-stops: list .5in;"><b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Action </span></b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">delegates from the <a href="http://msdn.microsoft.com/en-us/library/system%28VS.100%29.aspx"><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">System</span></a> namespace, for example, <a href="http://msdn.microsoft.com/en-us/library/018hxwa8%28VS.100%29.aspx"><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">Action</span></a> and <a href="http://msdn.microsoft.com/en-us/library/bb549311%28VS.100%29.aspx"><b><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">Action</span></b></a> (T, T1, T2, and so on are contravariant) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></li>
<li class="MsoNormalCxSpMiddle" style="color: black; line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo2; tab-stops: list .5in;"><b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Func</span></b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> delegates from the <a href="http://msdn.microsoft.com/en-us/library/system%28VS.100%29.aspx"><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">System</span></a> namespace, for example, <a href="http://msdn.microsoft.com/en-us/library/bb534960%28VS.100%29.aspx"><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">Func</span></a> and <a href="http://msdn.microsoft.com/en-us/library/bb549151%28VS.100%29.aspx"><b><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">Func</span></b></a> (TResult is covariant; T, T1, T2, and so on are contravariant) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></li>
<li class="MsoNormalCxSpMiddle" style="color: black; line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo2; tab-stops: list .5in;"><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><a href="http://msdn.microsoft.com/en-us/library/bfcke1bz%28VS.100%29.aspx"><b><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">Predicate</span></b></a> (T is contravariant) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></li>
<li class="MsoNormalCxSpMiddle" style="color: black; line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo2; tab-stops: list .5in;"><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><a href="http://msdn.microsoft.com/en-us/library/tfakywbh%28VS.100%29.aspx"><b><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">Comparison</span></b></a> (T is contravariant) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></li>
<li class="MsoNormalCxSpMiddle" style="color: black; line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo2; tab-stops: list .5in;"><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><a href="http://msdn.microsoft.com/en-us/library/kt456a2y%28VS.100%29.aspx"><b><span style="color: black; mso-bidi-font-size: 11.0pt; text-decoration: none; text-underline: none;">Converter</span></b></a> (TInput is contravariant; TOutput is covariant.) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></li>
</ul><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><br />
</div><div class="MsoNormalCxSpMiddle" style="line-height: 12.0pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;"><br />
</div></div>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-34594674148430176372011-04-11T02:57:00.000-07:002011-04-27T06:25:20.884-07:00Action vs Func vs Predicate delegates<div dir="ltr" style="text-align: left;" trbidi="on"><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>EN-US</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>HE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:DontVertAlignCellWithSp/> <w:DontBreakConstrainedForcedTables/> <w:DontVertAlignInTxbx/> <w:Word11KerningPairs/> <w:CachedColBalance/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="--"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/> <m:defJc m:val="centerGroup"/> <m:wrapIndent m:val="1440"/> <m:intLim m:val="subSup"/> <m:naryLim m:val="undOvr"/> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/> <w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/> <w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/> <w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/> <w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/> <w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/> <w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/> <w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/> <w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/> <w:LsdException Locked="false" Priority="37" Name="Bibliography"/> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin-top:0in;
mso-para-margin-right:0in;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0in;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}
</style> <![endif]--> <div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">If you are working with .Net 4.0, you must have come across tailored-made delegates like Action, Func or Predicate many times. Today I shall discuss about them and explain how they can be useful in your daily coding practices.</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Action delegate:</span></b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> Action delegate is an inbuilt delegate who can encapsulate any function that takes any type as input and returns nothing (void). If you see the metadata, Action delegate is nothing but</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">public</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">delegate</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">void</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Action</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">in</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> T>(T obj);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Example:</span></b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> Let say I want to encapsulate a function which prints the string input on console and which has return type void.</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Approach 1:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">class</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Program</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">public</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">delegate</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">void</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">myActionDel</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">string</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> s);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">static</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">void</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> Main(</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">string</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">[] args)</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">myActionDel</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> del = WriteToConsole;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> del(</span><span style="color: #a31515; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">"delegate works"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Console</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">.Read();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">public</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">static</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">void</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> WriteToConsole(</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">string</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> s)</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Console</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">.WriteLine(s);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">What I am doing here is defining a delegate which can takes a string input and returns void. I am wrappping a function "WriteToConsole" of same signature as my delegate and invoking the delegate.</span><span style="font-family: "; font-size: 10.0pt;"><br />
<br />
<br />
</span><b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Approach 2:</span></b><b><span style="font-family: "; font-size: 10.0pt;"> </span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">class</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Program</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">static</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">void</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> Main(</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">string</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">[] args)</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Action</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">string</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">> myActionDel = WriteToConsole;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> myActionDel(</span><span style="color: #a31515; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">"delegate works"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Console</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">.Read();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">public</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">static</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">void</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> WriteToConsole(</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">string</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> s)</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Console</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">.WriteLine(s);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">you can see here that I did not need to define a delegate explicitly since I knew that my Action delegate is a delegate which fulfills my purpose, it takes a single input parameter and does not return anything.</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><br />
<b>Examples from .NET framework: </b></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">1. Foreach in list type takes Action delegate as input. If you look the metadata of Foreach in list type, it will look like as following</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">public</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">void</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> ForEach(</span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Action</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> action);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">The following code will print "Abhishek" three times (on each invocation of delegate). You can also check below in how many different ways I can use the delegate.</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> List</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">string</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">> names = </span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">new</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">List</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">string</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">>();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> names.Add(</span><span style="color: #a31515; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">"Abhishek"</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: green; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">//anonymous delegate way</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> names.ForEach(</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">delegate</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">string</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> s) { </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Console</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">.WriteLine(s); });</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: green; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">//lambda expression way</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> names.ForEach(s => </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Console</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">.WriteLine(s));</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: green; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">//proper delegate way</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Action</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"><</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">string</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">> del = (</span><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">string</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> s) => { </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Console</span><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">.WriteLine(s); };</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> names.ForEach(del);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Func Delegate: </span></b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Now let’s discuss about Func delegate. This is the most used inbuilt delegate since it can take any number of parameters (though there is a cap but that is too high for our general purposes) and it can return a type. Looking at metadata for Func delegate which can encompass a function taking two input parameters and a return type looks something like below</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">public</span> <span style="color: blue;">delegate</span> TResult <span style="color: #2b91af;">Func</span><<span style="color: blue;">in</span> T1, <span style="color: blue;">in</span> T2, <span style="color: blue;">out</span> TResult>(T1 arg1, T2 arg2);</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Kindly note that when you define a Func delegate, the last parameter is always a return type.</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Example:</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">class</span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Program</span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Func</span><<span style="color: blue;">string</span>, <span style="color: blue;">string</span>> myFuncDel = WriteToConsole;</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Console</span>.WriteLine(myFuncDel(<span style="color: #a31515;">"This is an example of Func delegate"</span>));</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Console</span>.Read();</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">string</span> WriteToConsole(<span style="color: blue;">string</span> s)</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">return</span> s;</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Note that Func tells that this can encapsulate a function which takes a string input parameter and returns a string output.</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Predicate: </span></b><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Predicate is a delegate which takes any object type as input and returns a Boolean. A predicate is equivalent to</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">public</span> <span style="color: blue;">delegate</span> <span style="color: blue;">bool</span> <span style="color: #2b91af;">Predicate</span><<span style="color: blue;">in</span> T>(T obj);</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">or</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">public</span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Func</span><<span style="color: blue;">object</span>, <span style="color: blue;">bool</span>> myPredicate;</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">Predicates are designed to be used in places where you want to evaluate something and return a Boolean value based on whether your test passed or failed. </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Predicate</span><<span style="color: blue;">string</span>> MyPredicate = CheckMyName;</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"Is my name Abhishek: "</span> + MyPredicate(<span style="color: #a31515;">"Abhishek"</span>));</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: #2b91af;">Console</span>.Read();</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> CheckMyName(<span style="color: blue;">string</span> s)</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> {</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> <span style="color: blue;">return</span> s == <span style="color: #a31515;">"Abhishek"</span>;</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: black; font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">In .NET framework, you will find predicates used in for e.g. List.Find, Array.Find etc. </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";">public</span><span style="font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: "Courier New"; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"> T Find(<span style="color: #2b91af;">Predicate</span> match);</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-language: HE; mso-fareast-font-family: "Times New Roman";"></span></div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><br />
</div><div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><br />
</div><div class="MsoNormal"><br />
</div></div>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com3tag:blogger.com,1999:blog-6633841189462964052.post-87927870467573793512010-08-18T09:21:00.000-07:002010-08-31T04:14:27.515-07:00Best way to end ASP.NET sessionThere are mainly three methods in Session object which serve similar purpose.<br />
<br />
1. <b>Session.Clear():</b> This will immediately remove all objects stored inside Session object. Session object basically stores a collection of key(string) vs value(object). After calling this, you will find Session.count equals to zero but Session object itself will still be alive and you can again add new key/value items to it.<br />
<br />
2. <b>Session.RemoveAll(): </b>It behaves exactly the same way as Session.Clear. It just wraps Session.RemoveAt at one shot. You can specify index in Session.RemoveAt to remove items one by one. You can also call Session.Remove and pass key to remove that key/value pair item. It could be slower than Session.Clear which essentially is made just to clear all the items.<br />
<br />
3. <b>Session.Abandon(): </b>If you have used Session.Clear or Session.RemoveAll, though you have got rid of any and all objects stored in session but session object itself remains alive and could be used further. Session.Abandon just cancels the current session and session object gets destroyed.<br />
The only point to remember here is that if you have used Session.Abandon, it will just mark the session to be destroyed but nothing will happen to session object for that request. As soon as the current request gets completed, session object will be canceled. So don't get surprised if nothing looks to happening to session object just after calling the abandon method, in the next request, you will find that session object to be destroyed and a new one to be created.Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-83094185207374485972010-08-18T08:23:00.000-07:002010-08-31T04:13:42.196-07:00Take your web application offline without any change in web server or applicationThis might come handy when you are in maintenance mode of your application and you want to let your user know it. How would you do it without shutting down your application or without writing additional code to redirect all requests?<br />
The only thing you have to do is to create a file with name app_offline.htm, decorate it however you want and just put it inside the root directory of your application. Rest everything will be taken care of .NET handlers. All users visiting to your site will automatically see your offline page.<br />
Whenever you want your application to be up, just remove that file and that's it.Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-44363861572914595772010-06-29T08:58:00.000-07:002010-06-29T08:58:25.961-07:00Ternary operator in VB.NetIf you are looking for ternary operator in VB.NET similar to C++,C#, Javascript etc <b>if(expression?truepart:falsepart)</b> then let me tell you that VB.NET offers a similar <b>function</b> to do that<br />
<br />
you can write<br />
<br />
Dim displayName As String = "FirstName"<br />
Dim myName As String = IIf((displayName = "FirstName"), "Abhishek", "Tiwari")<br />
Console.WriteLine(myName) 'will write "Abhishek"<br />
myName = IIf((displayName = "SurName"), "Abhishek", "Tiwari")<br />
Console.WriteLine(myName) 'will write "Tiwari"<br />
<br />
Please note that IIf is just a function which takes first input as an expression, evaluate it and return second input (if expression is evaluated to true) or return third input (if expression is evaluated to false).<br />
<br />
There is a gotcha in using IIf function, it works little bit differently than ternary operator in C#. It basically evaluates both input (irrespective of expression evaluating to true or false). In Other languages, expression will be evaluated first and then based on the result other inputs will be evaluated.<br />
<br />
for e.g.<br />
<br />
Dim dict As New Dictionary(Of String, String)<br />
Dim d = IIf(dict.ContainsKey("A"), dict("A"), Nothing)<br />
<br />
will result in "KeyNotFound" exception although someone will assume that it should return Nothing without throwing exception.<br />
<br />
Fortunately VB.Net 9 provides conditional operator (If) to be used as ternary operator too and it works exactly the same way the ternary operator works in C# or other language.<br />
<br />
<br />
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">Dim dict As New Dictionary(Of String, String)</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">Dim d = If(dict.ContainsKey("A"), dict("A"), Nothing)</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><br />
</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">Note that I have used "If" instead of function "IIf" and later one will execute successfully and return Nothing without throwing any exception.</div>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com2tag:blogger.com,1999:blog-6633841189462964052.post-4277519780437683382010-06-25T09:16:00.000-07:002011-07-25T23:11:17.718-07:00Visual Studio 2010 crashing after unlocking windows XP<div dir="ltr" style="text-align: left;" trbidi="on">Good features come from Microsoft with plenty of bugs around. I am enjoying the powerfulness of Visual studio 2010 with VB.NET 10. Lots of new features have been added in VB.NET 10 (read my article <a href="http://aspnettechstuffs.blogspot.com/2010/06/cool-vbnet-10-features.html">http://aspnettechstuffs.blogspot.com/2010/06/cool-vbnet-10-features.html</a> ) and VS 2010 beautifully runs on top of them. I was living in a wonderful shell until one day I found VS 2010 started crashing everytime I unlock my windows XP machine. This gave me lots of trouble since everytime VS crashed it did not save any of my modified document and recovery options too did not be of too help everytime.<br />
I checked my event log and found following errors logged<br />
<br />
<i>System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.CodedUITestPackage, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.</i><br />
<i><br />
.NET Runtime version 2.0.50727.4927 - Fatal Execution Engine Error </i><br />
<i><br />
Faulting application name: devenv.exe, version: 10.0.20506.1,</i><br />
<br />
I could not reproduce the issue so far after disabling my hardware acceleration of my computer. Hope it may help you as well. If that does not work, you can also try to look into your VS 2010 Tools -> Options -> General -> Visual Experience and disable the hardware acceleration if it is enabled there.<br />
<br />
you can disable hardware accelartion of windows as following<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyniDPG5MVgd40CB_6zujc6yP7OGvVHu4QFds_L8xVOK9h52R9hi6m8K5RFmlB0sPsTaFwjhKtKPwgNLlXOHDH1JRE2ayqcr0HR5mZ-Gm1OjI8V5XrBGUWB64u39JxtK7DlSoSyd18BhU/s1600/HardwareAcceleration.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="253" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyniDPG5MVgd40CB_6zujc6yP7OGvVHu4QFds_L8xVOK9h52R9hi6m8K5RFmlB0sPsTaFwjhKtKPwgNLlXOHDH1JRE2ayqcr0HR5mZ-Gm1OjI8V5XrBGUWB64u39JxtK7DlSoSyd18BhU/s320/HardwareAcceleration.JPG" width="320" /></a></div></div>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com1tag:blogger.com,1999:blog-6633841189462964052.post-67718549969839543242010-06-25T08:44:00.000-07:002011-04-18T05:14:33.247-07:00Cool Visual Studio 2008/2010 extensions (plugins)<div dir="ltr" style="text-align: left;" trbidi="on">I have found couple of very useful VS extensions. I would like to recommend them to everyone using Visual studio 2008 or 2010. They are absolutely free to use.<br />
<br />
<b>VS Command:</b> Some of the interesting features of my choice are as following ( please refer <a href="http://mokosh.co.uk/vscommands/#download">http://mokosh.co.uk/vscommands/#download</a> for all details)<br />
<ul><li><b>Grouping & Ungrouping items</b> – you can group and ungroup items using IDE, something you would normally need to edit project file (DependentUpon) </li>
<li><b>Locate in solution </b>- some people don’t like auto tracking of current item in solution explorer but would like to locate current item on demand. It’s now easy to achieve, simply rightclick in code editor, select ‘Locate in Solution’ from context menu and current item will be highlighted in solution explorer. </li>
<li><b>Copy/Paste As Link - </b>You can create shortcuts to files and group them for later instant use</li>
<li><span style="color: #2e2e2e;"><b>Copy/Paste References</b> – </span>supports assembly, project and ActiveX references</li>
<li><b>Open Command Prompt - </b><span style="color: #2e2e2e;">Opens Visual Studio Command Prompt in a location of selected item (solution,project, project item or reference).</span></li>
<li><b>Open File Location</b><br />
Open file location works on solution items, link items and references.<b></b><br />
</li>
<li><span style="color: #2e2e2e;"><b>Build Summary</b></span><br />
<br />
<ol><li>Build Output has a summary section appended at the end of it.</li>
<li>The summary contains information about time it took to build each project and total build time.</li>
</ol></li>
</ul>Download link:<br />
<a href="http://cid-21abd8f967e9c775.skydrive.live.com/self.aspx/.Public/2008%5E_10%5E_VSCommands%5E5v1.2%5E6.msi">VSCommands 2008</a><br />
<a href="http://visualstudiogallery.msdn.microsoft.com/en-us/d491911d-97f3-4cf6-87b0-6a2882120acf">VSCommands 2010</a><br />
<br />
<b>Power Command:</b> Interesting features of my choice (read full article on <a href="http://code.msdn.microsoft.com/PowerCommands">Power Command for VS 2008 </a>and <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/e5f41ad9-4edc-4912-bca3-91147db95b99">Power Command for VS 2010</a> ) You will get download link from same articles.<br />
<br />
<ul><li><b>Email CodeSnippet - </b>To email the lines of text you select in the code editor, right-click anywhere in the editor and then click Email CodeSnippet. </li>
<li><b>Undo Close - </b>This command reopens a closed document , returning the cursor to its last position. To reopen the most recently closed document, point to the Edit menu, then click Undo Close. Alternately, you can use the Ctrl<span style="text-decoration: underline;">Shift</span>Z shortcut.<br />
To reopen any other recently closed document, point to the View menu, click Other Windows, and then click Undo Close Window. The Undo Close window appears, typically next to the Output window. Double-click any document in the list to reopen it.</li>
<li><b>Collapse Projects - </b>This command collapses a project or projects in the Solution Explorer starting from the root selected node. </li>
<li><b>Copy As Project Reference - </b>This command copies a project as a project reference to the clipboard. It can be executed from a project node.</li>
<li><b>Extract Constant - </b>This command creates a constant definition statement for a selected text. Extracting a constant effectively names a literal value, which can improve readability. This command can be executed from the code editor by right-clicking selected text.</li>
</ul><b>Productivity Power Tools: </b><br />
<a href="http://www.blogger.com/%20http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/"></a><br />
<a href="http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/">Productivity Power Tools</a> <br />
<br />
<ul></ul><ul></ul><ul></ul><ul></ul></div>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-37829190995806498012010-06-22T04:07:00.000-07:002010-06-22T04:07:03.542-07:00Nullable type in vb.netSince relational database support null values for every types, it makes sense that your application should also support null values. Reference types can directly take null values but value types are always initialized with their default values that makes it difficult to figure out whether they contain some actual value or not.<br />
One way developers used to achieve this by assigning some hypothetical value to a value type so that at any point of time looking at the value they would come to know whether that value type variable actually has been assigned or not.<br />
With .Net 2.0 it has been possible to create nullable value types that means you can assign a null value to a value type with keeping all other value type advantages intact. Nullable types can be declared in following manner<br />
<br />
Dim myNullable As Nullable(Of Integer)<br />
myNullable = 4<br />
Dim mynull As Integer? = 4<br />
<br />
if you are interested to know what type it returns for myNullable and myNull so it is "Integer?" in both of the cases. Interestingly Integer? is nothing but a wrapper over Integer class which provides an additional functionality.<br />
<br />
Nullable types contain a property called HasValue which provides you a better way to find out whether any value has been assigned by any time to your variable or not<br />
<br />
Dim hasSomeValue As Boolean = myNullable.HasValue<br />
<br />
will return me true or false based on myNullable has a null value or a valid integer.<br />
<br />
nullable types are initialized with 'NULL' in C# and with 'NOTHING' in vb.netAbhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-74959226785445462842010-06-22T00:12:00.000-07:002010-06-22T01:29:16.557-07:00cool vb.net 10 featuresI would like to introduce you new vb.net 2010 features some of which have been missing since long and developers were always craving for them. These new features are bundled with VB.Net in .NET framework 4.0 and they will surely going to improve developer's productivity and code quality .<br /><br /><span style="font-weight: bold;">Implicit line continuation: </span>You don't need to put underscore character at the end of the line to make compiler understand that this line is extending to next line. Though underscore is still needed in couple of cases for e.g. declaring attribute at the top of function or class. e.g.<br /><br /> Dim s As String = "Hello" &<br /> "World"<br /><br /> is a valid statement. Ofcourse if you want to make it more readable you should still use underscore as continuation<br /><br />Dim s As String = "Hello" _ 'using underscore otherwise it would be difficult<br />& "World" 'to understand if line is extended to next line or not<br /><br /><br /><span style="font-weight: bold;">Auto implemented properties:</span> Like C# in VB.NET too you don't need to write get/set functions if they are meant to be used as default. for e.g.<br /><br />Public Class Student<br /> Property Age As Integer<br /> Private _name As String<br /> Public Property Name() As String<br /> Get<br /> Return _name<br /> End Get<br /> Set(ByVal value As String)<br /> _name = value<br /> End Set<br /> End Property<br />End Class<br /><br />You can see Property "Age" is auto implemented and we don't need to explicitly write its get/set functions. Internally compiler will automatically generate the fields starting with underscore.<br /><br /><br /><span style="font-weight: bold;">Object initializer: </span>Now like C#, it is possible in vb.net to set object properties during the time of its initialization. We can construct the earlier mentioned Student class object as following<br /><br />Dim myStudent As New Student With {<br /> .Age = 20,<br /> .Name = "Abhishek"<br /> }<br /><br /><br /><span style="font-weight: bold;">Multiline lambda or Anonymous methods:</span> Earlier vb.net used to support single line anonymous method only which made using lambda or anonymous method bit annoying. you had to write statements something like this<br />Dim mySub = Sub() Debug.WriteLine("Difficult to write complex implementation")<br /><br />but now with vb.net 10 you can write multiline anonymous methods with ease<br /><br /> Dim mySub = Sub(newStudent As Student)<br /> Dim myStudent As New Student With {<br /> .Age = 20,<br /> .Name = "Abhishek"<br /> }<br /> newStudent = myStudent<br /> End Sub<br /><br /><span style="font-weight: bold;">Implicitly typed or inferred local variables (Anonymous types):</span> If you have worked in C#, it's exactly how 'var' is used in C#. The object type is inferred from the value it has been assigned. for e.g.<br /><br />Dim myInt = 4<br />Dim myString = "Abhishek"<br />Dim myStudent = New Student With {.Age = 20, .Name = "Abhishek"}<br /><br />Here how compiler is going to read it<br />Dim myInt As integer = 4<br />Dim myString As string= "Abhishek"<br />Dim myStudent As Student= New Student With {.Age = 20, .Name = "Abhishek"}<br /><br />In C# you cannot assign a null value to anonymous type ('var') but if the type of object is already inferred, you can assign a null value to it for e.g.<br />in C#<br />var myObj = null //not possible<br />*********************<br />var myStudent = New Student<br />myStudent = null //works<br /><br />in VB.Net<br />Dim myObj = nothing 'works<br />myObj will be inferred as 'object' type<br /><br />There are few more new features which I would love to mention in my next couple of posts for e.g. LinqToXML, QueryComprehension, Extension Methods etc.<br /><br />Happy reading!!!Abhishek Tiwarihttp://www.blogger.com/profile/13261447542085207851noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-84879236009413186102010-06-10T08:08:00.000-07:002010-06-10T08:19:49.635-07:00Sending disabled asp.net control's value in RequestUse the <em><strong>SubmitDisabledControls </strong></em>property to specify whether to force controls disabled on the client to submit their values when the page posts back. This allows the disabled controls to preserve their values after the page posts back to the server. When the SubmitDisabledControls property is set to false, controls on the form that have been disabled using client script will not be submitted to the server the next time the page posts back. As a result, any values stored by the disabled controls are lost. To allow the disabled controls to preserve their values after the page posts back to the server, set the SubmitDisabledControls property to true.<br /><br /><em><strong>SubmitDisabledControls </strong></em> property can be set on PageLoad or inside form tag in aspx page.Shailendra Pratap Singhhttp://www.blogger.com/profile/08802904112903214340noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-38743161443910669212010-06-07T22:00:00.000-07:002010-06-07T22:21:32.409-07:00System.Web.UI.PairThe Pair class is used as a basic structure to store two related objects. It is a utility class that is used in various ways throughout ASP.NET, such as during page state management tasks or in configuration section handlers. You can use the Pair class in your own code anywhere that you need a structure to contain two related objects.<br /><br />Through following example I am going to illustrate it's use in control state.<br /><br />Suupose you are overriding any ASP.NET control (for eg. GridView) and lets say view state is off. Now in this case we can use control state to store some custom properties.<br /> <em>Protected Overrides Function SaveControlState() As Object<br /> 'Get the state from base class<br /><br /> Dim baseState As Object = MyBase.SaveControlState()<br /><br /> 'Combine this state with objects you want to store and return<br /> 'the final object.<br /> Return New <strong>Pair</strong>(baseState, CurrentPageIndex) 'Where CurrentPageIndex is some custom property.<br /> End Function</em><br /><br /> <em> Protected Overrides Sub LoadControlState(ByVal savedState As Object)<br /> Dim pair As <strong>Pair</strong> = savedState<br /> If Not IsNothing(pair) Then<br /> 'Give the base class its state.<br /> MyBase.LoadControlState(pair.First)<br /> 'Now process the state you saved.<br /> <strong>CurrentPageIndex = pair.Second</strong><br /> End If<br /> End Sub</em>Shailendra Pratap Singhhttp://www.blogger.com/profile/08802904112903214340noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-33897935647339381482010-06-06T23:25:00.000-07:002010-06-06T23:29:52.906-07:00Override non-virtual (nonoverridable in vb.net) methodsYou might wonder if there is a possibility to override nonvirtual or nonoverridable (vb.net) methods. Suppose you are using a third party software then you may need to override some of its methods which are not declared as virtual, this is also a likely requirement when you are writing a wrapper to some existing controls/software/functionality.<br />
This is actually not overriding the actual function but it is called hiding the base class implementation and this can be implemented as following<br />
<br />
vb.net implementation:<br />
<br />
<br />
Class myBaseClass<br />
Public Function MyNonOverridableMethod() As String<br />
Return "I am not overridable"<br />
End Function<br />
<br />
End Class<br />
<br />
Class myDerivedClass<br />
Inherits myBaseClass<br />
Public Shadows Function MyNonOverridableMethod() As String<br />
Return "I overrode my base class function"<br />
End Function<br />
<br />
End Class<br />
<br />
Note that I have used keyword "shadows" here, which tells the runtime that these two functions are separate implementations (not correlated) in their respective classes.<br />
<br />
now when I call them from Main<br />
<br />
<br />
Sub Main()<br />
Dim b As myBaseClass = New myDerivedClass()<br />
Console.WriteLine(b.MyNonOverridableMethod())<br />
<br />
Dim d As myDerivedClass = New myDerivedClass()<br />
Console.WriteLine(d.MyNonOverridableMethod())<br />
<br />
Console.ReadLine()<br />
<br />
End Sub<br />
<br />
This will print me<br />
"I am not overridable"<br />
"I overrode my base class function"<br />
<br />
you can see, that this is still using runtime polymorphism, on runtime it sees that the function being called is not virtual so it has to be called from variable reference type (not the type of the object got created). Has the function being declared virtual, runtime will call it from the type of the object that has been created but not from the type of the reference pointer it is holding.(in case of base class function being declared virtual/nonoverridable and derived class overriding it, the previous example would always be printing "I overrode my base class function").<br />
<br />
C# implementation for same:<br />
<br />
<span class="Apple-style-span" style="color: #2e2e2e; font-family: 'Courier New', Courier, mono; font-size: 12px;"></span><br />
<pre class="brush:csharp" style="font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">public class myBaseClass
{
public string MyNonOverridableMethod()
{
return "I am not overridable";
}
}
public class myDerivedClass : myBaseClass
{
public new string MyNonOverridableMethod()
{
return "I overrode my base class function";
}
}</pre><pre class="brush:csharp" style="font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"></pre><pre class="brush:csharp" style="font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">The only difference is that "Shadows" keyword is replaced by "New".</pre><pre class="brush:csharp" style="font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"></pre><pre class="brush:csharp" style="font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">calling from Main will reproduce the same result.</pre><pre class="brush:csharp" style="font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"></pre><pre class="brush:csharp" style="font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: medium; white-space: normal;">
<pre class="brush:csharp" style="font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="Apple-style-span" style="font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; line-height: 13px; white-space: normal;">
<div class="line alt2" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><table style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="keyword" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">public</code> <code class="keyword" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">static</code> <code class="keyword" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">void</code> <code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Main()</code></td></tr>
</tbody></table></div><div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><table style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">11</code></td><td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="spaces" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"> </code><code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">{</code></td></tr>
</tbody></table></div><div class="line alt2" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><table style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">12</code></td><td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="spaces" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"> </code></td></tr>
</tbody></table></div><div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><table style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: 3em !important;"></td><td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"> myBaseClass b = </code><code class="keyword" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">new</code> <code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">myDerivedClass();</code></td></tr>
</tbody></table></div><div class="line alt2" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><table style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">14</code></td><td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="spaces" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"> </code><code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Console.WriteLine(b.MyNonOverridableMethod());</code></td></tr>
</tbody></table></div><div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><table style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">15</code></td><td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: auto !important;"></td></tr>
</tbody></table></div><div class="line alt2" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><table style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">16</code></td><td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="spaces" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"> </code><code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">myDerivedClass d = </code><code class="keyword" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 102, 153) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">new</code> <code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">myDerivedClass();</code></td></tr>
</tbody></table></div><div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><table style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">17</code></td><td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="spaces" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"> </code><code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Console.WriteLine(d.MyNonOverridableMethod());</code></td></tr>
</tbody></table></div><div class="line alt2" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><table style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">18</code></td><td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: auto !important;"></td></tr>
</tbody></table></div><div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><table style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">19</code></td><td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="spaces" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"> </code><code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">Console.ReadLine();</code></td></tr>
</tbody></table></div><div class="line alt2" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><table style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">20</code></td><td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: auto !important;"></td></tr>
</tbody></table></div><div class="line alt1" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><table style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">21</code></td><td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="spaces" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"> </code><code class="plain" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">}</code></td></tr>
</tbody></table></div><div class="line alt2" style="background-attachment: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><table style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-collapse: collapse !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(175, 175, 175) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-width: 0px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; padding-right: 0.3em !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: right !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;">22</code></td><td class="content" style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: none !important; background-origin: initial !important; border-bottom-width: 0px !important; border-color: initial !important; border-left-color: rgb(108, 226, 108) !important; border-left-style: solid !important; border-left-width: 3px !important; border-right-width: 0px !important; border-style: initial !important; border-top-width: 0px !important; bottom: auto !important; color: rgb(0, 0, 0) !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; font-style: normal !important; font-weight: normal !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin-bottom: 0px !important; margin-left: 0px !important; margin-right: 0px !important; margin-top: 0px !important; min-height: inherit !important; outline-color: initial !important; outline-style: initial !important; outline-width: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; padding-right: 0px !important; padding-top: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: top !important; width: auto !important;"></td></tr>
</tbody></table></div></span></pre></span></pre><pre class="brush:csharp" style="font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"></pre><pre class="brush:csharp" style="font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"></pre><pre class="brush:csharp" style="font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"></pre><pre class="brush:csharp" style="font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span class="Apple-style-span" style="font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; line-height: 13px; white-space: normal;"></span></pre>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com2tag:blogger.com,1999:blog-6633841189462964052.post-59933810652712073472010-06-06T04:55:00.000-07:002010-06-06T04:58:20.090-07:00call constructor from another constructor (VB.Net and C#)If you are using C#, you have to call one constructor from another by using inbuilt syntax (similar to one used during inheritance) for e.g.<br />
<br />
<br />
class TestConstructor<br />
{<br />
public TestConstructor()<br />
{<br />
//Default Constructor<br />
}<br />
<br />
public TestConstructor(string s):this()<br />
{<br />
//overloaded constructor<br />
}<br />
<br />
public TestConstructor(int n):this("test")<br />
{<br />
//overloaded constructor<br />
}<br />
}<br />
<br />
Now If I call it from main function as below<br />
<br />
static void Main(string[] args)<br />
{<br />
TestConstructor tc = new TestConstructor(4);<br />
}<br />
<br />
the constructor which takes integer as parameter would be called which will then call the constructor taking string as parameter and that will call default constructor. So my default constructor would be executed first followed by the one which takes string as parameter and the last one to be executed will be the one which takes integer as parameter.<br />
Please note that the constructors would always be called in a manner they are related to each other. so while writing the code you need to write the most common initialization in your default constructor and then keep on doing inheritance of constructor until your most uncommon initialization is required to be wrapped in a constructor.<br />
<br />
<br />
If you are using VB.NET then you have to write code as following<br />
<br />
<br />
Class TestConstructor<br />
Public Sub New()<br />
'Default Constructor<br />
End Sub<br />
<br />
Public Sub New(ByVal s As String)<br />
'overloaded Constructor<br />
Me.New()<br />
End Sub<br />
Public Sub New(ByVal n As Integer)<br />
'overloaded Constructor<br />
Me.New("this")<br />
End Sub<br />
<br />
End Class<br />
<br />
Now you can call it from Main<br />
<br />
<br />
Sub Main()<br />
Dim tc As New TestConstructor(4)<br />
End Sub<br />
<br />
and it will be executed similar to the example I mentioned for C#.<br />
<br />
Here you will find subtle difference in the language, VB.NET does not differentiate much between constructor and function so you can explicitly call a constructor from another assuming it to be a function. Therefore here order of calling constructors is completely upto you, you can call constructors with all liberty (same as when you call function).Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-91574327718199377332010-06-04T01:24:00.000-07:002010-06-04T01:55:43.574-07:00How JIT or runtime compilation happensEver wondered how .net runtime compilation works? Let me try to explain it to the best of my understanding.<br />
Lets take an example<br />
<br />
<br />
namespace TestConsole<br />
{<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
WriteHello();<br />
}<br />
<br />
public static void WriteHello()<br />
{<br />
Console.WriteLine("Hello");<br />
}<br />
}<br />
}<br />
<br />
At the runtime when CLR would see that there is a call to a function WriteHello, it will try to find out all the types used inside the function (here there is only one "Console"). It will then create an internal datastructure and put all the available members of those types into there and point them to an internal function "JITCompiler" something like as following<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBNwunoxF7dLeN9Y9MGtvThXMjIRwK2SJj8EUIctWVItsBSHpeKOOzofPRFAfIh4Sa9Y6gDDHvwAU9Vx9BjbnWPA-tOvTVvurpBiSaVD_Yk-kFB5M6oHFRDkAuskPigKpznd0OURLgtHg/s1600/JITCompiler.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="197" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBNwunoxF7dLeN9Y9MGtvThXMjIRwK2SJj8EUIctWVItsBSHpeKOOzofPRFAfIh4Sa9Y6gDDHvwAU9Vx9BjbnWPA-tOvTVvurpBiSaVD_Yk-kFB5M6oHFRDkAuskPigKpznd0OURLgtHg/s400/JITCompiler.JPG" width="400" /></a></div><br />
<br />
<br />
Then CLR invokes JITCompiler for all functions which have been used inside the current method for e.g. here we have only one function WriteLine. JITCompiler goes to assembly for type Console and looks into its metadata table. From there it will find the information about the actual implementation (IL code) of the function WriteLine. It creates some memory block and compiles that IL code to native memory using those blocks. it comes back and changes the pointer (which was earlier pointing to itself) to that memory block. refer following picture<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZNd38WIofAVBaGfVp3eh9Xl_kWvX0ZCJo1cfIpnlqySjo7IwubSXgLty4Azg7UsWdqFJVyDn44NWHdqHA03I7NMqo132zeomlu3s35W4nrg_sgXAVIyaG-CeFAmz0fHBhP9JjoIW9jl0/s1600/JITNative.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="262" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZNd38WIofAVBaGfVp3eh9Xl_kWvX0ZCJo1cfIpnlqySjo7IwubSXgLty4Azg7UsWdqFJVyDn44NWHdqHA03I7NMqo132zeomlu3s35W4nrg_sgXAVIyaG-CeFAmz0fHBhP9JjoIW9jl0/s640/JITNative.JPG" width="640" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<i>* please note that the function compiled should be void writeline(string s) (not void writeline). I shall correct the image sometime later.</i><br />
<br />
After JITCompiler job is done, it returns cursor back to Main function. Now CLR goes in Main function once again and executes it. Not to mention, that next time whenever JITCompiler will be invoked, it will work only for those functions who are pointing to it that means runtime compilation will happen only once. Kindly note that all native memory will be in persistance until your application is up, whenever you make any changes to your .vb or .cs file, it causes your application to be shutdown forcefully and start a new instance. As soon as your application will go down, all compiled code (into native memory) will be flushed and the whole process (runtime compilation) will start again for new instance of application.<br />
Since all the runtime compilation logic is inside function JITCompiler, people don't mind calling the complete process itself is JIT compilation.<br />
<br />
Hope this will clear your at least one important low level aspect of ASP.NET.Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-30970714395938628022010-05-31T01:30:00.001-07:002010-06-25T01:27:59.975-07:00index your site by search engines<ul><li>As soon as you create a new blog or site, submit it to google, this will help google to index and cache your site little bit faster. <a href="http://www.google.com/addurl/">http://www.google.com/addurl/</a></li>
<li> How will you let the whole world know about your updated content. Google may crawl your blog one day or there might be no day at all. I found autoping service to be very useful in this case. which can automatically ping to all search engines about your content almost as soon as you update them. <a href="http://autopinger.com/default.aspx">http://autopinger.com/default.aspx</a></li>
<li>put your blog url to as many places as you can. for e.g you can give your blog URL in your facebook, linkedin, orkut, twitter profile. You can use tools like bloglink (in linkedin) which will bring your every new post before whole world or atleast to people in your network. </li>
<li>Create new account at BlogCatalog( <a href="http://www.blogcatalog.com/">http://www.blogcatalog.com/</a> ) and mybloglog ( <a href="http://www.mybloglog.com/">http://www.mybloglog.com</a>) and ( <a href="http://www.blogratedirectory.com/">http://www.blogratedirectory.com</a> )and submit your blog. These sites are indexed very frequently and soon after submitting your blog you will find it listed in google search results.</li>
<li>you can submit your site to some search engines. If your site gets started coming up as the result in one of the search engine, it is highly likely that it will start coming up as the result from other search engine too. for e.g. on every update submit your site to <a href="http://www.activesearchresults.com/">http://www.activesearchresults.com/</a></li>
<li>the most important of above all is to create backlinks from other popular sites to your site. As many backlinks you will create, as good your site indexing and ranking will be. for e.g. create an account to aspnet forum ( <a href="http://forums.asp.net/">http://forums.asp.net/</a> ) submit your queries, answer other people queries but don't forget to mention your site or blog name everytime. these forums are indexed every day and hence so your blog or site name. There is an option to mention your blog or site name while creating your signature, by doing so you will never bother to mention everytime your site name since your signature will be appended to your every post.</li>
<li> integrate google analytics ( <a href="http://www.google.com/analytics/">http://www.google.com/analytics/ </a>) with your site to see how your visitors like you and add more and more of content of visitors' choice</li>
<li>Your site is as good to be indexed as popular it is and the popularity of your site would be decided by the no. of visitors of your site. You would like to attract new visitors but like to keep your old visitors and crave them to visit your site again and again. To keep your visitors alive on your site, give them options to subscribe to your site and its content. Provide them all easy options to subscribe to your site through its feed.</li>
<li>checkout other good articles</li>
<ul><li> <a href="http://www.affiliatebestprograms.com/how-to-get-indexed-by-google/">http://www.affiliatebestprograms.com/how-to-get-indexed-by-google/</a></li>
</ul></ul><div><br />
</div>Abhishek Tiwarihttp://www.blogger.com/profile/13261447542085207851noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-34973142118996482062010-05-28T03:27:00.000-07:002010-05-30T01:23:07.435-07:00Some important web statistics<b>Browsers:</b> Internet explorer is rapidly losing their market giving way to firefox to rule over the web. While most of the web browsers are making themselves compliant to latest HTML5, IE8 is the most incompatible browser for HTML5.<br /><img alt="html5 compatability 2" src="http://www.readwriteweb.com/images/html5_compatability_chitika.jpg" /><br />taken from: <a href="http://www.readwriteweb.com/archives/46_of_internet_users_ready_for_html5.php">http://www.readwriteweb.com/archives/46_of_internet_users_ready_for_html5.php</a><br /><br />check out the following browser statistics<br /><br /><br /><h2 style="background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; font-weight: normal; margin-bottom: 10px; margin-top: 10px;">Browser Statistics Month by Month</h2><table border="1" cellpadding="0" cellspacing="0" class="reference" style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px;"><tbody><tr><th style="background-color: #e5eecc; border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;" width="16%">2010</th><th style="background-color: #e5eecc; border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;" width="12%"><a href="http://www.w3schools.com/browsers/browsers_explorer.asp" style="background-color: transparent; color: #900b09;">IE8</a></th><th style="background-color: #e5eecc; border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;" width="12%"><a href="http://www.w3schools.com/browsers/browsers_explorer.asp" style="background-color: transparent; color: #900b09;">IE7</a></th><th style="background-color: #e5eecc; border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;" width="12%"><a href="http://www.w3schools.com/browsers/browsers_explorer.asp" style="background-color: transparent; color: #900b09;">IE6</a></th><th style="background-color: #e5eecc; border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;" width="12%"><a href="http://www.w3schools.com/browsers/browsers_firefox.asp" style="background-color: transparent; color: #900b09;">Firefox</a></th><th style="background-color: #e5eecc; border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;" width="12%"><a href="http://www.w3schools.com/browsers/browsers_chrome.asp" style="background-color: transparent; color: #900b09;">Chrome</a></th><th style="background-color: #e5eecc; border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;" width="12%"><a href="http://www.w3schools.com/browsers/browsers_safari.asp" style="background-color: transparent; color: #900b09;">Safari</a></th><th style="background-color: #e5eecc; border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;" width="12%"><a href="http://www.w3schools.com/browsers/browsers_opera.asp" style="background-color: transparent; color: #900b09;">Opera</a></th></tr><tr><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">April</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">16.2%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">9.3%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">7.9%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">46.4%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">13.6%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">3.7%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">2.2%</td></tr><tr><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">March</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">15.3%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">10.7%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">8.9%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">46.2%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">12.3%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">3.7%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">2.2%</td></tr><tr><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">February</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">14.7%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">11.0%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">9.6%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">46.5%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">11.6%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">3.8%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">2.1%</td></tr><tr><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">January</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">14.3%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">11.7%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">10.2%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">46.3%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">10.8%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">3.7%</td><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">2.2%</td></tr></tbody></table><br /><br />taken from: <a href="http://www.w3schools.com/browsers/browsers_stats.asp">http://www.w3schools.com/browsers/browsers_stats.asp</a><br /><br />Not to mention that web developers should start seriously thinking of making their application run smoothly on Firefox and Chrome as well.<div><br /></div><div><edited></div><div><div><i>Kindly note that here I do not want to correlate between HTML5 and market share, I just want to share some fronts on which IE is still improving itself to keep its feet still and firm in the market.</i></div><div><i>In my IE9 preview </i><a href="http://aspnettechstuffs.blogspot.com/2010/05/ie9-preview.html"><i>http://aspnettechstuffs.blogspot.com/2010/05/ie9-preview.html</i></a><i> article, I have shared some links where tech pundits have criticized Microsoft for their poor vision and low sightedness. Google is backing HTML5 big time and so is Firefox. Microsoft was reluctant to make changes and do any kind of experiment with IE. The time went on and Firefox made itself 46% HTML5 compliant in its version 3.5 that wide opened MS eyes and now they are trying hard to put any and everything in IE9 that all their competitor browser has but not IE8.</i></div><div><i>Netscape, Opera, Safari just to name few started glory but later vanished by IE. With robust security, less loading time, less CPU usage, hundreds of smart addins (all developed by open source community) on the same line Firefox is pushing IE back all the corners. </i></div><br /><b>Display resolution: </b>web developers should concentrate making their application usable for resolution 1024*768 or more. check out this statistics<br /><br /><table border="1" cellpadding="0" cellspacing="0" class="reference" style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px;"><tbody><tr><th style="background-color: #e5eecc; border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;" width="20%">Date</th><th align="right" style="background-color: #e5eecc; border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">Higher</th><th align="right" style="background-color: #e5eecc; border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">1024x768</th><th align="right" style="background-color: #e5eecc; border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">800x600</th><th align="right" style="background-color: #e5eecc; border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">640x480</th><th align="right" style="background-color: #e5eecc; border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">Unknown</th></tr><tr><td style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">January 2010</td><td align="right" style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;"><a href="http://www.w3schools.com/browsers/browsers_resolution_higher.asp" style="background-color: transparent; color: #900b09;">76%</a></td><td align="right" style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">20%</td><td align="right" style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">1%</td><td align="right" style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">0%</td><td align="right" style="border-bottom-color: rgb(195, 195, 195); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(195, 195, 195); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(195, 195, 195); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(195, 195, 195); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-bottom: 3px; padding-left: 3px; padding-right: 3px; padding-top: 3px; vertical-align: top;">3%</td></tr></tbody></table><br /><br />taken from: <a href="http://www.w3schools.com/browsers/browsers_display.asp">http://www.w3schools.com/browsers/browsers_display.asp</a><br /><br />There are other interesting statistics as well mentioned on renowned w3schools site, if it interests you, please follow this link<br /><a href="http://www.w3schools.com/browsers/default.asp">http://www.w3schools.com/browsers/default.asp</a></div>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0tag:blogger.com,1999:blog-6633841189462964052.post-43991983293900370822010-05-27T03:47:00.000-07:002010-05-27T04:45:03.073-07:00Script# (JavaScript with C#)There is a good news for people who are expert in C# but are afraid to write complex code in JavaScript. Microsoft has already started working on it and their first internal release has already happened. C# compiler will compile a class to .js file (instead of IL). You need to import certain libraries and implement IScriptlet to start with. Please note that most of the oops related functionalities like Inheritance, Polymorphism, delegates etc can smoothly be translated into javascript. Couple of C# features like Generics etc are currently kept out of conversion to script.<br />
You might be aware of the fact that the Google has already done the same. They are using J2EE classes which can be converted to javascript. There is another company Morfik who are said to be pioneer into this. They are going to provide this functionality for C#, Java, Pascal and VB (visual basic).<br />
<br />
My hats off to Nikhil Kothari with whose vision this javascript compiler will soon be reality in coming days. Please read his blog to know more on Script#<br />
<a href="http://www.nikhilk.net/ScriptSharpIntro.aspx">http://www.nikhilk.net/ScriptSharpIntro.aspx</a>Abhishekhttp://www.blogger.com/profile/13666599807723810311noreply@blogger.com0