tag:blogger.com,1999:blog-65202026465325644382024-03-04T23:58:08.821-08:00Ravinder Singh Bhawer (Id="Ravinder" runat="Server")I am a Web Developer in aps.net technology .Presently working in G-Asra Tech Ludhiana(Punjab), IndiaRavinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.comBlogger35125tag:blogger.com,1999:blog-6520202646532564438.post-73691797233120950982013-09-30T22:59:00.000-07:002013-09-30T22:59:42.407-07:00virtual (C# Reference).<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; padding-bottom: 15px;">
The <span class="input" style="font-weight: 700;">virtual</span> keyword is used to modify a method, property, indexer, or event declaration and allow for it to be overridden in a derived class. For example, this method can be overridden by any class that inherits it:</div>
<div class="codeSnippetContainer" id="code-snippet-1" style="clear: both; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 17px; min-width: 260px;" xmlns="">
<div class="codeSnippetContainerTabs" style="height: 23px; position: relative; vertical-align: middle; z-index: 1;">
</div>
<div class="codeSnippetContainerCodeContainer" style="border: 1px solid rgb(147, 147, 147); clear: both; margin-bottom: 12px; position: relative; top: -1px;">
<div class="codeSnippetToolBar" style="height: auto; width: auto;">
<div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 0px; padding-right: 0px; position: relative; top: -8px; vertical-align: top; width: auto;">
</div>
</div>
<div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_fd11a426-1705-449d-bae8-c2332bf892f2" style="margin: 0px; padding: 10px 21px; width: auto;">
<div style="margin: 0px; padding: 0px;">
<pre style="font-family: Consolas, Courier, monospace; overflow: auto; padding: 5px; word-wrap: normal;">public virtual double Area()
{
return x * y;
}</pre>
<pre style="font-family: Consolas, Courier, monospace; overflow: auto; padding: 5px; word-wrap: normal;"><span style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; line-height: 18px; white-space: normal;">The implementation of a virtual member can be changed by an </span><a href="http://msdn.microsoft.com/en-us/library/ebca9ah3.aspx" style="color: #03697a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; line-height: 18px; text-decoration: none; white-space: normal;">overriding member</a><span style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; line-height: 18px; white-space: normal;"> in a derived class. For more information about how to use the </span><span style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; line-height: 18px; white-space: normal;"><span class="input" style="font-weight: 700;">virtual</span></span><span style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; line-height: 18px; white-space: normal;"> keyword, see</span><span style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; line-height: 18px; white-space: normal;"><a href="http://msdn.microsoft.com/en-us/library/6fawty39.aspx" style="color: #03697a; text-decoration: none;">Versioning with the Override and New Keywords (C# Programming Guide)</a></span><span style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; line-height: 18px; white-space: normal;"> and </span><span style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; line-height: 18px; white-space: normal;"><a href="http://msdn.microsoft.com/en-us/library/ms173153.aspx" style="color: #03697a; text-decoration: none;">Knowing When to Use Override and New Keywords (C# Programming Guide)</a></span><span style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; line-height: 18px; white-space: normal;">.</span></pre>
<pre style="font-family: Consolas, Courier, monospace; overflow: auto; padding: 5px; word-wrap: normal;">
</pre>
<pre style="font-family: Consolas, Courier, monospace; overflow: auto; padding: 5px; word-wrap: normal;"><div style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; line-height: 18px; padding-bottom: 15px; white-space: normal;">
When a virtual method is invoked, the run-time type of the object is checked for an overriding member. The overriding member in the most derived class is called, which might be the original member, if no derived class has overridden the member.</div>
<div style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; line-height: 18px; padding-bottom: 15px; white-space: normal;">
By default, methods are non-virtual. You cannot override a non-virtual method.</div>
<div style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; line-height: 18px; padding-bottom: 15px; white-space: normal;">
You cannot use the <span class="input" style="font-weight: 700;">virtual</span> modifier with the <span class="input" style="font-weight: 700;">static</span>, <span class="input" style="font-weight: 700;">abstract, private</span>, or <span class="input" style="font-weight: 700;">override</span> modifiers. The following example shows a virtual property:</div>
<div style="color: #2a2a2a; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; line-height: 18px; padding-bottom: 15px; white-space: normal;">
<span style="color: blue; font-family: Consolas, Courier, monospace; line-height: 17px;">class</span><span style="font-family: Consolas, Courier, monospace; line-height: 17px;"> MyBaseClass</span></div>
</pre>
<pre style="font-family: Consolas, Courier, monospace; overflow: auto; padding: 5px; word-wrap: normal;">{
<span style="color: green;">// virtual auto-implemented property. Overrides can only </span>
<span style="color: green;">// provide specialized behavior if they implement get and set accessors. </span>
<span style="color: blue;">public</span> <span style="color: blue;">virtual</span> <span style="color: blue;">string</span> Name { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: green;">// ordinary virtual property with backing field </span>
<span style="color: blue;">private</span> <span style="color: blue;">int</span> num;
<span style="color: blue;">public</span> <span style="color: blue;">virtual</span> <span style="color: blue;">int</span> Number
{
<span style="color: blue;">get</span> { <span style="color: blue;">return</span> num; }
<span style="color: blue;">set</span> { num = value; }
}
}
<span style="color: blue;">class</span> MyDerivedClass : MyBaseClass
{
<span style="color: blue;">private</span> <span style="color: blue;">string</span> name;
<span style="color: green;">// Override auto-implemented property with ordinary property </span>
<span style="color: green;">// to provide specialized accessor behavior. </span>
<span style="color: blue;">public</span> <span style="color: blue;">override</span> <span style="color: blue;">string</span> Name
{
<span style="color: blue;">get</span>
{
<span style="color: blue;">return</span> name;
}
<span style="color: blue;">set</span>
{
<span style="color: blue;">if</span> (value != String.Empty)
{
name = value;
}
<span style="color: blue;">else</span>
{
name = <span style="color: #a31515;">"Unknown"</span>;
}
}
}
}</pre>
</div>
</div>
</div>
</div>
</div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-49159248161896556622013-09-24T03:18:00.003-07:002013-09-24T03:18:51.730-07:00Get next N rows from sql server .. and some other use full sql queries .. <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
<br />
<b>Get next N rows from sql server .. and some other use full sql queries .. </b><br />
<br />
<a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/MSSQLServer/using-offset-n-rows-fetch-next-n-rows-on" target="_blank">http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/MSSQLServer/using-offset-n-rows-fetch-next-n-rows-on</a></div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-57888434207470628632013-09-06T02:43:00.005-07:002013-09-06T02:43:46.607-07:00MVC Interview Questions and Answers (All about MVC)<div dir="ltr" style="text-align: left;" trbidi="on">
<h1 id="ctl00_ArticleTitle" itemprop="name" style="background-color: white; color: #333333; font-family: 'Segoe UI', Arial, sans-serif; font-size: 29px; font-weight: 200; margin: 0px 0px 7px; padding: 0px;">
MVC Interview Questions and Answers (All about MVC)</h1>
<br />
<a href="http://www.codeproject.com/Articles/639717/MVC-Interview-Questions-and-Answers-All-about-MVC">http://www.codeproject.com/Articles/639717/MVC-Interview-Questions-and-Answers-All-about-MVC</a><br />
<br /></div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-70521098958238825372013-08-30T03:46:00.001-07:002013-08-30T03:46:53.071-07:00How to Hide Files in JPEG Pictures<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://www.online-tech-tips.com/computer-tips/hide-file-in-picture/">http://www.online-tech-tips.com/computer-tips/hide-file-in-picture/</a></div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com1tag:blogger.com,1999:blog-6520202646532564438.post-59717364292635044522013-08-27T02:10:00.000-07:002013-08-27T02:10:06.983-07:00Angular.js example application with local storage ... <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Follow the link.<br />
<br />
<a href="http://www.codeproject.com/Articles/637430/Angular-js-example-application">http://www.codeproject.com/Articles/637430/Angular-js-example-application</a></div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-28730516308158341242013-08-27T01:51:00.001-07:002013-08-27T01:51:27.834-07:00Chat Application with SignalR and ASP.net MVC 4<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
Here I have used Visual Studio 2012 and ASP.net MVC 4 Web Application</div>
<div>
<br /></div>
<a href="http://tech.pro/tutorial/1491/chat-application-with-signalr-and-aspnet-mvc-4?goback=%2Egde_1779887_member_266049422#%21">http://tech.pro/tutorial/1491/chat-application-with-signalr-and-aspnet-mvc-4?goback=%2Egde_1779887_member_266049422#%21</a><br /></div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-46891623639126917752013-06-30T22:11:00.005-07:002013-06-30T22:11:47.867-07:00MySQL Fundamentals<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h1 style="background-color: white; border: 0px; color: #e76e34; font-family: myriad-pro-condensed; font-size: 26px; line-height: inherit; list-style: none; margin: 15px 0px 0px 10px; outline: 0px; padding: 0px; vertical-align: baseline;">
MySQL Fundamentals</h1>
<div style="background-color: white; border: 0px; color: #555555; font-family: myriad-pro, 'Lucida Grande', 'Lucida Sans Unicode', Arial, Helvetica, Verdana, sans-serif; font-size: 15px; line-height: 21px; list-style: none; margin-left: 10px; outline: 0px; padding: 0px; vertical-align: baseline;">
Fundamentals of MySQL, an essential part of the LAMP stack.</div>
<br />
<a href="http://pluralsight.com/training/Courses/TableOfContents/mysql-fundamentals-part1?utm_source=sqlauthority&utm_medium=sidebar&utm_content=latest&utm_campaign=newlook">http://pluralsight.com/training/Courses/TableOfContents/mysql-fundamentals-part1?utm_source=sqlauthority&utm_medium=sidebar&utm_content=latest&utm_campaign=newlook</a></div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-17414868933186124042013-06-30T22:02:00.001-07:002013-06-30T22:02:42.164-07:00Awesome demo for asp.net application ...... it just wow ... <div dir="ltr" style="text-align: left;" trbidi="on">
Try this , enjoy it <br />
<br />
<a href="http://demo.aspnetawesome.com/">http://demo.aspnetawesome.com</a></div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-69546404876965864572013-06-05T04:24:00.001-07:002013-06-05T04:24:16.506-07:00Jqgrid with asp.net mvc is just awesome .. <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<b>Please follow the below link for download sample application in asp.net mvc </b><br />
<b>this is just easy to implement with rich functionality inside ... this boom must try </b><br />
<br />
<br />
demo page link ..<br />
<a href="http://www.trirand.net/demoaspnetmvc.aspx">http://www.trirand.net/demoaspnetmvc.aspx</a><br />
<br />
download link .<br />
<br />
<b><a href="http://www.trirand.net/download.aspx">http://www.trirand.net/download.aspx</a> </b><br />
<b><br /></b>
<b><br /></b>
<b><br /></b>
<br />
<br /></div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-40318971406518918382013-03-28T22:12:00.001-07:002013-03-28T22:12:52.847-07:00Asp.Net Mvc With Web Api <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
<br />
ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. With WebAPI content negotiation, one can return data based on the client requests. What I mean is, if the client is requesting the data to be returned as JSON or XML, the WebAPI framework deals with the request type and returns the data appropriately based on the media type. By default WebAPI provides JSON and XML based responses.<br />
<br />
WebAPI is an ideal platform for building pure HTTP based services where the request and response happens with HTTP protocol. The client can make a GET, PUT, POST, and DELETE request and get the WebAPI response appropriately.<br />
<br />
In Summary, the WebAPI is<br />
<br />
- An HTTP Service<br />
<br />
- Designed for broad reach<br />
<br />
- Uses HTTP as an Application protocol, not a transport protocol<br />
<br />
<br />
<br />
Web API Architecture .<br />
<br />
We shall see below the Web API architecture when you are hosting the WebAPI in ASP.NET and self-hosting through console or windows service.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.codeproject.com/KB/aspnet/549152/WebHosting-Architecture.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="320" src="http://www.codeproject.com/KB/aspnet/549152/WebHosting-Architecture.png" width="201" /></a><a href="http://www.codeproject.com/KB/aspnet/549152/Selfhosting-Archiecture.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://www.codeproject.com/KB/aspnet/549152/Selfhosting-Archiecture.png" width="200" /></a></div>
<br />
<br />
<br />
<a href="http://www.codeproject.com/Articles/549152/Introduction-to-ASP-NET-Web-API" target="_blank">Follow this link </a> for the detail article ....<br />
</div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-71156500888501620782013-02-21T00:17:00.000-08:002013-02-21T00:27:16.163-08:00Send Mail from gmail server <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Reuiqred Name space " using System.Net.Mail; "<br />
<b><span style="color: #6aa84f;">//// (1) Create the MailMessage instance</span></b><br />
<b><span style="color: #6aa84f;"><br /></span></b>
MailMessage mm = new MailMessage();<br />
<span style="color: #6aa84f;"><br /></span>
<span style="color: #6aa84f;"><b> ////'(2) Assign the MailMessage's properties</b></span><br />
<span style="color: #6aa84f;"><b><br /></b></span>
mm.From = new MailAddress("info@gmail.com", "Ravi");<br />
<br />
mm.To.Add("Example@gmail.com");<br />
<br />
mm.Subject = "Any Subject ";<br />
<br />
mm.Body = ex.Message.ToString(); //Body of your mail<br />
<br />
mm.IsBodyHtml = false;//<br />
<br />
<b><span style="color: #6aa84f;"> ////'(3) Create the SmtpClient object</span></b><br />
<br />
<br />
SmtpClient smtp = new SmtpClient("smtp.gmail.com",587);<br />
<br />
smtp.EnableSsl = true;<br />
<br />
//smtp.DeliveryMethod = SmtpDeliveryMethod.Network; //it may be depend on your network<br />
<br />
<b><span style="color: #6aa84f;">//'(4) Send the MailMessage (will use the Web.config settings)</span></b><br />
<br />
smtp.Credentials = new System.Net.NetworkCredential("GmailId", "Passward"); <br />
smtp.Send(mm);</div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-84198229593457197962013-01-16T04:50:00.004-08:002013-01-16T04:50:59.228-08:00Send mail from sql server <div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; text-align: justify;">Let me start this blog post with negative note: SQL Server is not mass mailing software. If you are thinking of sending emails using SQL Server instead of your mail server – I suggest you stop doing that NOW! Whenever, I see any application using SQL Server as a mail server – I always vote against it. Well, if this is so bad, then why is it possible to send email through SQL Server. The reason is simple – there are many SQL Server Administrative scenarios where we need SQL Server to send emails, e.g. Maintenance task status, job failure messages, operators alerts etc. I suggest to use Database mail option during this situation. Click below </span><a href="http://blog.sqlauthority.com/2013/01/16/sql-server-send-email-from-sql-database-configure-database-mail-sql-in-sixty-seconds-039-video/">follow this link for more details </a></div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-26172842087451575782012-12-24T05:51:00.001-08:002012-12-24T05:51:10.501-08:00what a trcik must check <div dir="ltr" style="text-align: left;" trbidi="on">
http://blog.sqlauthority.com/2012/12/19/sql-server-select-and-delete-duplicate-records-sql-in-sixty-seconds-036-video/</div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-2512423543268580002012-12-20T07:58:00.001-08:002012-12-20T07:58:23.026-08:00hashtable in asp.net c#<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: verdana, helvetica, arial, sans-serif; font-size: 12px;">The Hashtable object contains items in key/value pairs. The keys are used as indexes, and very quick searches can be made for values by searching through their keys.</span><br />
<span style="background-color: white; font-family: verdana, helvetica, arial, sans-serif; font-size: 12px;"><br /></span>
<span style="background-color: white; font-family: verdana, helvetica, arial, sans-serif; font-size: 12px;"><br /></span>
<br />
<pre class="lang-cs prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; line-height: 17.27272605895996px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="typ" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2b91af; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">Hashtable</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"> hashtable </span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: darkblue; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">new</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2b91af; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">Hashtable</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">();</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">
key </span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="lit" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: maroon; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">1</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">;</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">
name </span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="str" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: maroon; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">"A"</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">;</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">
hashtable</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2b91af; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">Add</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">key</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">name</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">
key </span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="lit" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: maroon; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">2</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">;</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">
name </span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="str" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: maroon; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">"B"</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">;</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">
hashtable</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2b91af; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">Add</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">key</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">name</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">
key </span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="lit" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: maroon; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">3</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">;</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">
name </span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="str" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: maroon; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">"lily"</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">;</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">
hashtable</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2b91af; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">Add</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">key</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">name</span><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">);</span></code></pre>
<pre class="lang-cs prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; line-height: 17.27272605895996px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span></code></pre>
<pre class="lang-cs prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; line-height: 17.27272605895996px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span></code></pre>
<pre class="lang-cs prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; line-height: 17.27272605895996px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span></code></pre>
<pre class="lang-cs prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; line-height: 17.27272605895996px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">u can use foreach loop for read </span></code></pre>
<pre class="lang-cs prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; line-height: 17.27272605895996px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">
</span></code></pre>
<pre class="lang-cs prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; line-height: 17.27272605895996px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="pun" style="background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="kwd" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: darkblue; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">foreach</span> (<span class="kwd" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: darkblue; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">string</span> key <span class="kwd" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: darkblue; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">in</span> hashtable.<span class="typ" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2b91af; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">Keys</span>) {
<span class="typ" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2b91af; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">Response</span>.<span class="typ" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #2b91af; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">Write</span>(key + <span class="str" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: maroon; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">'='</span> + hashtable[key] + <span class="str" style="background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: maroon; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;">"<br>"</span>);
}</span></code></pre>
</div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-3972033696475550992012-12-14T00:55:00.000-08:002012-12-14T00:55:47.456-08:00Sealed Classes in c# , .Net <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div align="justify" style="background-color: white; color: #333333; font-family: 'segoe UI'; font-size: small; outline: none 0px;">
<span style="font-family: Verdana, Arial, Helvetica, sans-serif; outline: none 0px;">Sealed classes are used to restrict the inheritance feature of object oriented programming. Once a class is defined as <strong style="outline: none 0px;">sealed class,</strong> this class cannot be inherited. </span><br style="outline: none 0px;" /><span style="font-family: Verdana, Arial, Helvetica, sans-serif; outline: none 0px;">In C#, the sealed modifier is used to define a class as <strong style="outline: none 0px;">sealed</strong>. In Visual Basic .NET,<strong style="outline: none 0px;">NotInheritable</strong> keyword serves the purpose of sealed. If a class is derived from a sealed class, compiler throws an error. </span><span style="font-family: Verdana, Arial, Helvetica, sans-serif; outline: none 0px;"><br style="outline: none 0px;" />If you have ever noticed, structs are sealed. You cannot derive a class from a struct. </span><br style="outline: none 0px;" /><span style="font-family: Verdana, Arial, Helvetica, sans-serif; outline: none 0px;">The following class definition defines a sealed class in C#: </span><br style="outline: none 0px;" /></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="color: green; font-family: Consolas; font-size: 9.5pt; outline: none 0px;">// Sealed class</span><span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"><o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt; outline: none 0px;">sealed</span><span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"> <span style="color: blue; outline: none 0px;">class</span> <span style="color: #2b91af; outline: none 0px;">SealedClass</span><o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;">{<o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"><span style="outline: none 0px;"> </span><o:p style="outline: none 0px;"></o:p></span><span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;">}</span><span style="font-family: Verdana, Arial, Helvetica, sans-serif; outline: none 0px;"><span style="color: green; font-size: x-small; outline: none 0px;"> </span></span><br style="outline: none 0px;" /><span style="font-family: Verdana, Arial, Helvetica, sans-serif; outline: none 0px;"><span style="color: green; font-size: x-small; outline: none 0px;"></span><span style="font-size: x-small; outline: none 0px;"><br style="outline: none 0px;" /></span>In the following code, I create a sealed class <strong style="outline: none 0px;">SealedClass</strong> and use it from Class1. If you run this code, it will work fine. But if you try to derive a class from sealed class, you will get an error.</span> <br style="outline: none 0px;" /><span style="font-family: Verdana, Arial, Helvetica, sans-serif; outline: none 0px;"><br style="outline: none 0px;" /></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt; outline: none 0px;">using</span><span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"> System;<o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt; outline: none 0px;">class</span><span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"> <span style="color: #2b91af; outline: none 0px;">Class1</span><o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;">{<o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"><span style="outline: none 0px;"> </span><span style="color: blue; outline: none 0px;">static</span> <span style="color: blue; outline: none 0px;">void</span> Main(<span style="color: blue; outline: none 0px;">string</span>[] args)<o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"><span style="outline: none 0px;"> </span>{<o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"><span style="outline: none 0px;"> </span><span style="color: #2b91af; outline: none 0px;">SealedClass</span> sealedCls = <span style="color: blue; outline: none 0px;">new</span> <span style="color: #2b91af; outline: none 0px;">SealedClass</span>();<o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"><span style="outline: none 0px;"> </span><span style="color: blue; outline: none 0px;">int</span> total = sealedCls.Add(<span style="color: brown; outline: none 0px;">4</span>, <span style="color: brown; outline: none 0px;">5</span>);<o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"><span style="outline: none 0px;"> </span><span style="color: #2b91af; outline: none 0px;">Console</span>.WriteLine(<span style="color: #a31515; outline: none 0px;">"Total = "</span> + total.ToString());<o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"><span style="outline: none 0px;"> </span>}<o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;">}<o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="color: green; font-family: Consolas; font-size: 9.5pt; outline: none 0px;">// Sealed class</span><span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"><o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt; outline: none 0px;">sealed</span><span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"> <span style="color: blue; outline: none 0px;">class</span> <span style="color: #2b91af; outline: none 0px;">SealedClass</span><o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;">{<o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"><span style="outline: none 0px;"> </span><span style="color: blue; outline: none 0px;">public</span> <span style="color: blue; outline: none 0px;">int</span> Add(<span style="color: blue; outline: none 0px;">int</span> x, <span style="color: blue; outline: none 0px;">int</span> y)<o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"><span style="outline: none 0px;"> </span>{<o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"><span style="outline: none 0px;"> </span><span style="color: blue; outline: none 0px;">return</span> x + y;<o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;"><span style="outline: none 0px;"> </span>}<o:p style="outline: none 0px;"></o:p></span></div>
<div class="MsoNormal" style="background-color: white; color: #333333; font-family: Calibri, sans-serif; font-size: 11pt; margin: 0in 0in 0pt; outline: none 0px;">
<span style="font-family: Consolas; font-size: 9.5pt; outline: none 0px;">}<o:p style="outline: none 0px;"></o:p></span><span style="font-family: Verdana, Arial, Helvetica, sans-serif; outline: none 0px;"> <br style="outline: none 0px;" /><span style="font-size: x-small; outline: none 0px;"><br style="outline: none 0px;" /></span></span><span style="font-family: Verdana, Arial, Helvetica, sans-serif; outline: none 0px;"><strong style="outline: none 0px;"><br style="outline: none 0px;" />Why Sealed Classes?</strong></span> <br style="outline: none 0px;" /><br style="outline: none 0px;" /><span style="font-family: Verdana, Arial, Helvetica, sans-serif; outline: none 0px;">We just saw how to create and use a sealed class. The main purpose of a sealed class to take away the inheritance feature from the user so they cannot derive a class from a sealed class. One of the best usage of sealed classes is when you have a class with static members. For example, the <strong style="outline: none 0px;">Pens</strong> and <strong style="outline: none 0px;">Brushes</strong> classes of the <strong style="outline: none 0px;">System.Drawing</strong>namespace. </span><br style="outline: none 0px;" /><span style="font-family: Verdana, Arial, Helvetica, sans-serif; outline: none 0px;">The Pens class represent the pens for standard colors. This class has only static members. For example, Pens.Blue represents a pen with blue color. Similarly, the Brushes class represents standard brushes. The Brushes.Blue represents a brush with blue color.</span> <br style="outline: none 0px;" /><span style="font-family: Verdana, Arial, Helvetica, sans-serif; outline: none 0px;">So when you're designing your application, you may keep in mind that you have sealed classes to seal user's boundaries.</span> <br style="outline: none 0px;" /><span style="font-family: Verdana, Arial, Helvetica, sans-serif; outline: none 0px;">In the next article of this series, I will discuss some usage of abstract classes.</span> </div>
</div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-86641166292982847632012-12-12T23:21:00.000-08:002012-12-13T02:18:07.785-08:00Http Handler and http Modules <div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<br />
<div style="background-color: white; color: #111111; font-size: 13.63636302947998px;">
<b><span style="font-family: Trebuchet MS, sans-serif;">ASP.NET handles all the <code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;">HTTP</code> requests coming from the user and generates the appropriate response for it. ASP.NET framework knows how to process different kind of requests based on extension, for example, It can handle request for<em style="border: 0px; margin: 0px; padding: 0px;">.aspx</em>, <em style="border: 0px; margin: 0px; padding: 0px;">.ascx</em> and <em style="border: 0px; margin: 0px; padding: 0px;">.txt</em> files, etc. When it receives any request, it checks the extension to see if it can handle that request and performs some predefined steps to serve that request.</span></b></div>
<br /><div style="background-color: white; color: #111111; font-size: 13.63636302947998px;">
<b><span style="font-family: Trebuchet MS, sans-serif;">Now as a developer, we might want to have some of our own functionality plugged in. We might want to handle some new kind of requests or perhaps we want to handle an existing request ourselves to have more control on the generated response, for example, we may want to decide how the request for <em style="border: 0px; margin: 0px; padding: 0px;">.jpg</em> or <em style="border: 0px; margin: 0px; padding: 0px;">.gif</em> files will be handled. Here, we will need an<code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;">HTTPHandler</code> to have our functionality in place.</span></b></div>
<div style="background-color: white; color: #111111; font-size: 13.63636302947998px;">
<b><span style="font-family: Trebuchet MS, sans-serif;">There are also some scenarios where we are ok with the way ASP.NET is handling the requests but we want to perform some additional tasks on each request, i.e., we want to have our tasks execute along with the predefined steps ASP.NET is taking on each request. If we want to do this, we can have <code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;">HTTPModule</code> in place to achieve that.</span></b></div>
<div style="background-color: white;">
<div style="color: #111111; font-size: 13.63636302947998px;">
<b><span style="font-family: Trebuchet MS, sans-serif;">So from the above discussion, it is clear that <code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;">HTTPHandlers</code> are used by ASP.NET to handle the specific requests based on extensions. <code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;">HTTPModule</code>, on the other hand, is used if we want to have our own functionality working along with the default ASP.NET functionality. There is one Handler for a specific request but there could be N number of modules for that.</span></b></div>
<div style="color: #111111; font-size: 13.63636302947998px;">
<b><span style="font-family: Trebuchet MS, sans-serif;"><br /></span></b></div>
<div style="color: #111111; font-size: 13.63636302947998px;">
<b><span style="font-family: Trebuchet MS, sans-serif;"><br /></span></b></div>
<b style="color: #111111; font-size: 13.63636302947998px;"><span style="font-family: Trebuchet MS, sans-serif;">For more detail visit </span></b><br />
<a href="http://www.codeproject.com/Articles/335968/Implementing-HTTPHandler-and-HTTPModule-in-ASP-NET">Click here</a><br />
<br /></div>
</div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-66675407459614803502012-12-12T04:14:00.003-08:002012-12-12T04:14:45.947-08:00Union and Union All<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;">
<strong style="margin: 0px; padding: 0px;">UNION</strong><br style="margin: 0px; padding: 0px;" />The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected.</div>
<div style="background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;">
<strong style="margin: 0px; padding: 0px;">UNION ALL</strong><br style="margin: 0px; padding: 0px;" />The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.</div>
<div style="background-color: white; color: #333333; font-family: verdana, tahoma, arial, sans-serif; font-size: 12px; line-height: 19.453125px; margin-bottom: 0.7em; margin-top: 0.7em; padding: 0px; text-align: justify;">
The difference between Union and Union all is that Union all will not eliminate duplicate rows, instead it just pulls all rows from all tables fitting your query specifics and combines them into a table.</div>
</div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-36598020646247462742012-12-11T23:16:00.001-08:002012-12-11T23:16:14.074-08:00Magic tables In sql server <div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;">Magic tables are nothing but INSERTED, DELETED table scope level, These are not physical tables, only Internal tables. </span><br style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;" /><br style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;" /><span style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;">This Magic table are used In SQL Server 6.5, 7.0 & 2000 versions with Triggers only. </span><br style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;" /><br style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;" /><span style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;">But, In SQL Server 2005, 2008 & 2008 R2 Versions can use these Magic tables with Triggers and Non-Triggers also. </span><br style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;" /><br style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;" /><b style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;">Using with Triggers:</b><span style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;"> </span><br style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;" /><span style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;">If you have implemented any trigger for any Tables then, </span><br style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;" /><span style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;">1.Whenever you Insert a record on that table, That record will be there on INSERTED Magic table. </span><br style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;" /><span style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;">2.Whenever you Update the record on that table, That existing record will be there on DELETED Magic table and modified New data with be there in INSERTED Magic table. </span><br style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;" /><span style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;">3.Whenever you Delete the record on that table, That record will be there on DELETED Magic table Only. </span><br style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;" /><br style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;" /><span style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;">These magic table are used inside the Triggers for tracking the data transaction. </span><br style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;" /><br style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;" /><span style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;">Using Non-Triggers: </span><br style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;" /><span style="font-family: Verdana, Arial, Tahoma; font-size: 13px; text-align: justify;">You can also use the Magic tables with Non-Trigger activities using OUTPUT Clause in SQL Server 2005, 2008 & 2008 R2 versions. </span></div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-37329767688557850962012-12-11T21:17:00.000-08:002012-12-11T21:17:12.669-08:00Common Language Runtime (CLR)<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px;">
<b>The .NET Framework provides a run-time environment called the common language runtime, which runs the code and provides services that make the development process easier.</b></div>
<div style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; margin-top: -6px;">
<b>Compilers and tools expose the common language runtime's functionality and enable you to write code that benefits from this managed execution environment. Code that you develop with a language compiler that targets the runtime is called managed code; it benefits from features such as cross-language integration, cross-language exception handling, enhanced security, versioning and deployment support, a simplified model for component interaction, and debugging and profiling services.</b></div>
</div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-60397787313775051412012-12-07T04:58:00.004-08:002012-12-07T04:58:58.786-08:00Cord first entity framwork <div dir="ltr" style="text-align: left;" trbidi="on">
<b>try the link for learn in breif </b><br />
<b><br /></b>
<b>http://msdn.microsoft.com/en-us/data/gg685467.aspx</b></div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-50717758405221164512012-12-07T03:28:00.002-08:002012-12-07T03:28:51.617-08:00Interface in c#<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h1 style="margin-bottom: 4.05pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;">
<span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 16.5pt; font-weight: normal;">Interfaces in C# (For Beginners)<o:p></o:p></span></h1>
<div class="MsoNormal">
<span style="color: #ff9900; font-family: 'Segoe UI', sans-serif; font-size: 11.5pt;">Introduction</span></div>
<form>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">Interfaces
in C # provide a way to achieve runtime polymorphism. Using interfaces we can
invoke functions from different classes through the same Interface reference,
whereas using virtual functions we can invoke functions from different classes
in the same inheritance hierarchy through the same reference. Before things start
getting difficult let me start using simple and short examples to explain the
concept of interfaces. Here's a short example that shows you what an interface
looks like.<o:p></o:p></span><br />
<h3>
<span style="color: #666666; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt; font-weight: normal; line-height: 115%;">P1.cs<o:p></o:p></span></h3>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg0" o:spid="_x0000_i1064" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">class</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">static</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Main()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"Hello Interfaces"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">interface</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{ <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
</div>
<h4>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 9.0pt; line-height: 115%;">Output<o:p></o:p></span></h4>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg1" o:spid="_x0000_i1063" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">Hello Interfaces<o:p></o:p></span></pre>
</div>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">The
above program compiles and runs successfully to produce the desired output. The
above program consists of a class</span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">and within it an entry point function</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Main()</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">that prints Hello Interfaces. The above
program also defines an interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">.
Interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">is empty at this point of time. Let's
add some elements to this interface.<o:p></o:p></span><br />
<h3>
<span style="color: #666666; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt; font-weight: normal; line-height: 115%;">P2.cs<o:p></o:p></span></h3>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg2" o:spid="_x0000_i1062" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">class</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">static</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Main()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"Hello Interfaces"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">interface</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">int</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> x; <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
</div>
<h4>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 9.0pt; line-height: 115%;">Output<o:p></o:p></span></h4>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg3" o:spid="_x0000_i1061" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">P2.cs(11,3): error CS0525: Interfaces cannot contain fields<o:p></o:p></span></pre>
</div>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">Error!
Interfaces in C# cannot contain fields i.e variables. The above program
declared an integer variable</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">x</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">in the interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">. And that's what hit the C#
compiler badly.<o:p></o:p></span><br />
<h3>
<span style="color: #666666; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt; font-weight: normal; line-height: 115%;">P3.cs<o:p></o:p></span></h3>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg4" o:spid="_x0000_i1060" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">class</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">static</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Main()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"Hello Interfaces"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">interface</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"In xyz"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> } <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
</div>
<h4>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 9.0pt; line-height: 115%;">Output<o:p></o:p></span></h4>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg5" o:spid="_x0000_i1059" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">P3.cs(11,8): error CS0531: 'abc.xyz()': interface members cannot have a <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;"> definition<o:p></o:p></span></pre>
</div>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">This
time over we included a function</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">xyz()</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">inside the interface found that this too
hurt the C# compiler. It told us loudly that interface members cannot have a
defination. Does this mean that if we just have a function declaration inside
the interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">that is fine with the C# compiler? Let's
find it out.<o:p></o:p></span><br />
<h3>
<span style="color: #666666; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt; font-weight: normal; line-height: 115%;">P4.cs<o:p></o:p></span></h3>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg6" o:spid="_x0000_i1058" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">class</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">static</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Main()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"Hello Interfaces"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">interface</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
</div>
<h4>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 9.0pt; line-height: 115%;">Output<o:p></o:p></span></h4>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg7" o:spid="_x0000_i1057" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">Hello Interfaces<o:p></o:p></span></pre>
</div>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">The
above program compiles and runs successfully to produce the desired output.
Finally we made the compiler happy. Interfaces in C# can only contain function
declarations. Now let us see interfaces in action.<o:p></o:p></span><br />
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">Interfaces
are contracts that a class implements in its own way. This means an interface
will contain function prototypes and a class that marries this interface will
have to take the responsibility of defining the functions whose prototypes are
declared by the marrying interface.<o:p></o:p></span><br />
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">So
its time to perform the marriage between our groom class</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">and the bride interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">.<o:p></o:p></span><br />
<h3>
<span style="color: #666666; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt; font-weight: normal; line-height: 115%;">P4.cs<o:p></o:p></span></h3>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg8" o:spid="_x0000_i1056" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">class</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo : abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">static</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Main()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"Hello Interfaces"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">interface</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
</div>
<h4>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 9.0pt; line-height: 115%;">Output<o:p></o:p></span></h4>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg9" o:spid="_x0000_i1055" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">P4.cs(1,7): error CS0535: 'Demo' does not implement interface member <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;"> 'abc.xyz()'<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">P4.cs(11,8): (Location of symbol related to previous error)<o:p></o:p></span></pre>
</div>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">Well,
in the above program class</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">did marry the interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">through the line class</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">demo : abc</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">but as usual there's a small
misunderstanding between the newlyweds. Class</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">needs to take the responsibility of
defining the functions whose prototypes are declared by the marrying interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">. Since class</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">in the above program has not been
implemented i.e. defined the function</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">xyz</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">whose prototype is declared by the
marrying interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">we get an error in the above program. To
fix this issue, the class</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">has to take the responsiility of
defining the function</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">xyz</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">whose
prototype is declared by the marrying interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">. And that is what you get
to see in the following program.<o:p></o:p></span><br />
<h3>
<span style="color: #666666; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt; font-weight: normal; line-height: 115%;">P5.cs<o:p></o:p></span></h3>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg10" o:spid="_x0000_i1054" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">class</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo : abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">static</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Main()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"Hello Interfaces"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"In xyz"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> } <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">interface</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
</div>
<h4>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 9.0pt; line-height: 115%;">Output<o:p></o:p></span></h4>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg11" o:spid="_x0000_i1053" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">a.cs(1,7): error CS0536: 'Demo' does not implement interface member <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;"> 'abc.xyz()'.'Demo.xyz()' is either static, not public, <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;"> or has the wrong return type.<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">a.cs(16,8): (Location of symbol related to previous error)<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">a.cs(7,8): (Location of symbol related to previous error)<o:p></o:p></span></pre>
</div>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">Error
again! It's not enough for the class</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">to implement the function</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">xyz</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">. It has to impress the
bride interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">by declaring its implementation of</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">xyz</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">as public. And that's what is done by
the following program.<o:p></o:p></span><br />
<h3>
<span style="color: #666666; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt; font-weight: normal; line-height: 115%;">P6.cs<o:p></o:p></span></h3>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg12" o:spid="_x0000_i1052" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">class</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo : abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">static</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Main()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"Hello Interfaces"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"In xyz"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> } <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">interface</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
</div>
<h4>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 9.0pt; line-height: 115%;">Output<o:p></o:p></span></h4>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg13" o:spid="_x0000_i1051" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">Hello Interfaces<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">In xyz<o:p></o:p></span></pre>
</div>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">Bingo!
The above program compiles and runs successfully to produce the desired output.
As mentioned earlier using interfaces we can invoke functions from different
classes using the same interface reference. For this, we need to have different
classes to implement the same interface. In the above program our class</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">is implementing the interface</span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">.
Let's have another class</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Sample</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">that implements the interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">.<o:p></o:p></span><br />
<h3>
<span style="color: #666666; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt; font-weight: normal; line-height: 115%;">P7.cs<o:p></o:p></span></h3>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg14" o:spid="_x0000_i1050" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">class</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo : abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">static</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Main()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"Hello Interfaces"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo refDemo = </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">new</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> refDemo.xyz();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Sample refSample = </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">new</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Sample();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> refSample.xyz(); <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"In Demo :: xyz"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> } <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">interface</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">class</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Sample : abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"In Sample :: xyz"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> } <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
</div>
<h4>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 9.0pt; line-height: 115%;">Output<o:p></o:p></span></h4>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg15" o:spid="_x0000_i1049" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">In Demo :: xyz<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">In Sample :: xyz<o:p></o:p></span></pre>
</div>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">The
above program compiles and runs successfully to produce the desired output.</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">refDemo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">is a reference to the object of class</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">.</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">refSample</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">is a reference to the object of class</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Sample</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">. Both the classes
implement the interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">and
hence define their own implementation of the function</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">xyz()</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">. From within the
entry point function</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Main()</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">xyz()</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">of the respective
classes</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">and</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Sample</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">are invoked through references</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">refDemo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">and</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">refSample</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">.<o:p></o:p></span><br />
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">Now
that we have two different classes implementing the same interface its time to
show you how to invoke functions from different classes using the same
interface reference.<o:p></o:p></span><br />
<h3>
<span style="color: #666666; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt; font-weight: normal; line-height: 115%;">P8.cs<o:p></o:p></span></h3>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg16" o:spid="_x0000_i1048" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">class</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo : abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">static</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Main()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"Hello Interfaces"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abc refabc = </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">new</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> refabc.xyz();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abc refabc = </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">new</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Sample();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> refabc.xyz(); <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"In Demo :: xyz"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> } <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">interface</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">class</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Sample : abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"In Sample :: xyz"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> } <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
</div>
<h4>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 9.0pt; line-height: 115%;">Output<o:p></o:p></span></h4>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg17" o:spid="_x0000_i1047" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">In Demo :: xyz<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">In Sample :: xyz<o:p></o:p></span></pre>
</div>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">The
above program compiles and runs successfully to produce the desired output.
Inside</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Main()</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">we have an interface reference</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">refabc</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">of type interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">. Reference of object of
class Demo is stored in</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">refabc</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">and</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">xyz()</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">of class</span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">is invoked using</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">refabc</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">. Next, the reference
of object of class Sample is stored in</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">refabc</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">and</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">xyz()</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">of class</span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Sample</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">is invoked using</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">refabc</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">. Thus, we were able
to invoke</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">xyz()</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">that belongs to different classes</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">and</span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Sample</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">via a common interface reference</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">refabc</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">.<o:p></o:p></span><br />
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">The
following program uses a for loop to invoke the functions of different classes</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">and</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Sample</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">that implement the same interface
"interface abc" using a single interface reference</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">refabc</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">whose type matches the interface
"interface abc" which the classes impliment.<o:p></o:p></span><br />
<h3>
<span style="color: #666666; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt; font-weight: normal; line-height: 115%;">P9.cs<o:p></o:p></span></h3>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg18" o:spid="_x0000_i1046" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">class</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo : abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">static</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Main()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abc [] refabc = {</span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">new</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo(), </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">new</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Sample()} ;<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">for</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> (</span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">int</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> i = </span><span class="code-digit"><span lang="CS" style="border: none windowtext 1.0pt; color: navy; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">0</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">; i<= </span><span class="code-digit"><span lang="CS" style="border: none windowtext 1.0pt; color: navy; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">1</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">; i++)<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> refabc[i].xyz();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"In Demo :: xyz"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> } <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">interface</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">class</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Sample : abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"In Sample :: xyz"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> } <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
</div>
<h4>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 9.0pt; line-height: 115%;">Output<o:p></o:p></span></h4>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg19" o:spid="_x0000_i1045" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">In Demo :: xyz<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">In Sample :: xyz<o:p></o:p></span></pre>
</div>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">The
above program compiles and runs successfully to produce the desired output.</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">refabc</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">is an array of type interface</span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">. It
stores the references to objects of classes</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">and</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Sample</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">. In the for loop,
using the array refabc, we are invoking the function</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">xyz()</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">of class</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">and</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Sample</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">. A class can
impliment as many interfaces as it wants. Take the following program.<o:p></o:p></span><br />
<h3>
<span style="color: #666666; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt; font-weight: normal; line-height: 115%;">P10.cs<o:p></o:p></span></h3>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg20" o:spid="_x0000_i1044" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">class</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo : abc, def<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">static</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Main()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"Hello Interfaces"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abc refabc = </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">new</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Demo();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> refabc.xyz();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"In xyz"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> } <o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">public</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> pqr()<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System.Console.WriteLine(</span><span class="code-string"><span lang="CS" style="border: none windowtext 1.0pt; color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">"In xyz"</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">interface</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abc<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> xyz();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">interface</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> def<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span class="code-keyword"><span lang="CS" style="border: none windowtext 1.0pt; color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-border-alt: none windowtext 0in; padding: 0in;">void</span></span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> pqr();<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></pre>
</div>
<h4>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 9.0pt; line-height: 115%;">Output<o:p></o:p></span></h4>
<div align="right" class="MsoNormal" style="text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg21" o:spid="_x0000_i1043" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Collapse<span class="apple-converted-space"> </span>|<span class="apple-converted-space"> </span></span><a href="http://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners"><span style="border: none windowtext 1.0pt; color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%; mso-border-alt: none windowtext 0in; padding: 0in;">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">Hello Interfaces<o:p></o:p></span></pre>
<pre style="background-position: initial initial; background-repeat: initial initial; border: none; padding: 0in;"><span style="font-family: Consolas; font-size: 9pt;">In xyz<o:p></o:p></span></pre>
</div>
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">The
above program compiles and runs successfully to produce a desired output. Class</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">implements interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">and thereby function</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">xyz()</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">. Class</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">also impliments interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">def</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">and thereby function</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">pqr()</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">.</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">ref abc</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">which is a variable of type Interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">, refers to object of class</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">. Next</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">xyz()</span></code><span class="apple-converted-space"><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast; padding: 0in;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">of</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">Demo</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">is invoked via</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">refabc</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">as</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">refabc</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">is a variable of type Interface</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">abc</span></code><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">which contains the prototype for
function</span><span class="apple-converted-space"><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-theme-font: major-fareast;"> </span></span><code><span style="border: none windowtext 1.0pt; color: #990000; font-family: Consolas; font-size: 11.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">xyz()</span></code><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt;">.</span><br />
<div align="right" class="MsoNormal" style="text-align: right;">
<br /></div>
</form>
</div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-35821702536031994532012-12-07T03:24:00.000-08:002012-12-07T03:24:41.540-08:00Abstract class in c# ,asp.net <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 4.05pt;">
<span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 16.5pt; mso-fareast-font-family: "Times New Roman"; mso-font-kerning: 18.0pt;">All
about abstract classes.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: grey; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">By</span><span style="color: grey; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><a href="http://www.codeproject.com/script/Membership/View.aspx?mid=450403"><b><span style="color: grey; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Jayababu</span></b></a><span style="color: grey; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">,</span><span style="color: grey; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> 26 Feb 2004</span><span style="color: grey; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<table border="0" cellpadding="0" class="MsoNormalTable">
<tbody>
<tr>
<td style="padding: 0in 0in 0in 0in;">
<table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable">
<tbody>
<tr>
<td nowrap="" style="padding: 0in 0in 0in 0in;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="border: none windowtext 1.0pt; color: #cccccc; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes; padding: 0in;"><v:shapetype coordsize="21600,21600" filled="f" id="_x0000_t75" o:preferrelative="t" o:spt="75" path="m@4@5l@4@11@9@11@9@5xe" stroked="f">
<v:stroke joinstyle="miter">
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0">
<v:f eqn="sum @0 1 0">
<v:f eqn="sum 0 0 @1">
<v:f eqn="prod @2 1 2">
<v:f eqn="prod @3 21600 pixelWidth">
<v:f eqn="prod @3 21600 pixelHeight">
<v:f eqn="sum @0 0 1">
<v:f eqn="prod @6 1 2">
<v:f eqn="prod @7 21600 pixelWidth">
<v:f eqn="sum @8 21600 0">
<v:f eqn="prod @7 21600 pixelHeight">
<v:f eqn="sum @10 21600 0">
</v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:formulas>
<v:path gradientshapeok="t" o:connecttype="rect" o:extrusionok="f">
<o:lock aspectratio="t" v:ext="edit">
</o:lock></v:path></v:stroke></v:shapetype><v:shape alt="http://s.codeproject.com/script/Ratings/Images/stars-fill-lg.png" id="Picture_x0020_1" o:spid="_x0000_i1037" style="height: 14.25pt; mso-wrap-style: square; visibility: visible; width: 104.25pt;" type="#_x0000_t75">
<v:imagedata o:title="stars-fill-lg" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png">
</v:imagedata></v:shape></span><span style="border: none windowtext 1.0pt; color: #cccccc; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="border: none windowtext 1.0pt; color: #cccccc; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes; padding: 0in;"><v:shape alt="http://s.codeproject.com/script/Ratings/Images/stars-empty-lg.png" id="Picture_x0020_2" o:spid="_x0000_i1036" style="height: 14.25pt; mso-wrap-style: square; visibility: visible; width: 104.25pt;" type="#_x0000_t75">
<v:imagedata o:title="stars-empty-lg" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image002.png">
</v:imagedata></v:shape></span><span style="border: none windowtext 1.0pt; color: #cccccc; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;"><o:p></o:p></span></div>
</td>
<td nowrap="" style="padding: 0in 0in 0in 0in;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #cccccc; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #cccccc; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #cccccc; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;"> </span><span style="color: #cccccc; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">4.55 </span><span style="border: none windowtext 1.0pt; color: #cccccc; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">(</span><span style="color: #cccccc; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">148 votes</span><span style="border: none windowtext 1.0pt; color: #cccccc; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">)</span><span style="color: #cccccc; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
</td>
<td style="padding: 0in 0in 0in 0in;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
</td>
</tr>
</tbody></table>
<div style="border-bottom: solid windowtext 1.0pt; border: none; mso-border-bottom-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 0in 0in 1.0pt 0in;">
<div align="center" class="MsoNormal" style="border: none; margin-bottom: 0.0001pt; padding: 0in; text-align: center;">
<span style="display: none; font-family: "Arial","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman"; mso-hide: all;">Top of Form<o:p></o:p></span></div>
</div>
<div class="MsoNormal" style="margin: 11.5pt 0in 6.35pt;">
<b><span style="color: #ff9900; font-family: "Segoe UI","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Introduction<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">Abstract classes are
one of the essential behaviors provided by .NET. Commonly, you would like to
make classes that only represent base classes, and don’t want anyone to create
objects of these class types. You can make use of abstract classes to implement
such functionality in C# using the modifier '</span><span lang="CS" style="color: #990000; font-family: Consolas; mso-ansi-language: CS; mso-fareast-font-family: "Times New Roman";">abstract</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">'.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">An abstract class
means that, no object of this class can be instantiated, but can make
derivations of this.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">An example of an
abstract class declaration is:<o:p></o:p></span></div>
<div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg0" o:spid="_x0000_i1035" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">Collapse</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">|</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><a href="http://www.codeproject.com/Articles/6118/All-about-abstract-classes"><span style="color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">class</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> absClass<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></div>
</div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">An abstract class can
contain either abstract methods or non abstract methods. Abstract members do
not have any implementation in the abstract class, but the same has to be
provided in its derived class.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">An example of an
abstract method:<o:p></o:p></span></div>
<div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg1" o:spid="_x0000_i1034" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">Collapse</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">|</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><a href="http://www.codeproject.com/Articles/6118/All-about-abstract-classes"><span style="color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">class</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> absClass<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">public</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">void</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abstractMethod();<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></div>
</div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">Also, note that an
abstract class does not mean that it should contain abstract members. Even we
can have an abstract class only with non abstract members. For example:<o:p></o:p></span></div>
<div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg2" o:spid="_x0000_i1033" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">Collapse</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">|</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><a href="http://www.codeproject.com/Articles/6118/All-about-abstract-classes"><span style="color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">class</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> absClass<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">public</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">void</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> NonAbstractMethod()<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">
Console.WriteLine(</span><span lang="CS" style="color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"NonAbstract Method"</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></div>
</div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">A sample program that
explains abstract classes:<o:p></o:p></span></div>
<div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg3" o:spid="_x0000_i1032" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">Collapse</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">|</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><a href="http://www.codeproject.com/Articles/6118/All-about-abstract-classes"><span style="color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">using</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> System;<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<br /></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">namespace</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> abstractSample<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//Creating
an Abstract Class<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">class</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> absClass<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//A
Non abstract method<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">public</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> AddTwoNumbers(</span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num1, </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num2)<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">return</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num1 + Num2;<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<br /></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//An
abstract method, to be<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//overridden
in derived class<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">public</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> MultiplyTwoNumbers(</span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num1, </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num2);<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<br /></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//A
Child Class of absClass<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">class</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> absDerived:absClass<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">
[STAThread]<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">static</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">void</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Main(</span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">string</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">[] args)<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//You
can create an<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//instance
of the derived class<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<br /></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">
absDerived calculate = </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">new</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> absDerived();<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> added =
calculate.AddTwoNumbers(</span><span lang="CS" style="color: navy; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">10</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">,</span><span lang="CS" style="color: navy; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">20</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> multiplied =
calculate.MultiplyTwoNumbers(</span><span lang="CS" style="color: navy; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">10</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">,</span><span lang="CS" style="color: navy; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">20</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">);<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">
Console.WriteLine(</span><span lang="CS" style="color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"Added : {0}, <o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="color: purple; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> Multiplied : {1}"</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">, added, multiplied);<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<br /></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//using
override keyword,<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//implementing
the abstract method<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//MultiplyTwoNumbers<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">public</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">override</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> MultiplyTwoNumbers(</span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num1, </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num2)<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">return</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num1 * Num2;<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></div>
</div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">In the above sample,
you can see that the abstract class</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">absClass</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">contains two methods</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">AddTwoNumbers</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">and</span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">MultiplyTwoNumbers</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">AddTwoNumbers</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">is a non-abstract method which contains implementation and</span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">MultiplyTwoNumbers</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">is an abstract method that does not contain implementation.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">The class</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">absDerived</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">is derived from</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">absClass</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">and the</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">MultiplyTwoNumbers</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">is implemented on</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">absDerived</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">. Within the</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span lang="CS" style="color: #990000; font-family: Consolas; mso-ansi-language: CS; mso-fareast-font-family: "Times New Roman";">Main</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">, an instance (</span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">calculate</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">) of the</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">absDerived</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">is created, and calls</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">AddTwoNumbers</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">and</span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">MultiplyTwoNumbers</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">. You can derive an abstract class from another abstract class.
In that case, in the child class it is optional to make the implementation of
the abstract methods of the parent class.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 11.5pt 0in 6.35pt;">
<b><span style="color: #ff9900; font-family: "Segoe UI","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Example<o:p></o:p></span></b></div>
<div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg4" o:spid="_x0000_i1031" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">Collapse</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">|</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><a href="http://www.codeproject.com/Articles/6118/All-about-abstract-classes"><span style="color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//Abstract Class1<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">class</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> absClass1<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">public</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> AddTwoNumbers(</span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num1, </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num2);<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">public</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> MultiplyTwoNumbers(</span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num1, </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num2);<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<br /></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//Abstract Class2<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">class</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> absClass2:absClass1<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//Implementing
AddTwoNumbers<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">public</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">override</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> AddTwoNumbers(</span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num1, </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num2)<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">return</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num1+Num2;<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<br /></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//Derived class from
absClass2<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">class</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> absDerived:absClass2<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//Implementing
MultiplyTwoNumbers<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">public</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">override</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> MultiplyTwoNumbers(</span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num1, </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num2)<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">return</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num1*Num2;<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></div>
</div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">In the above example,</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">absClass1 </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">contains
two abstract methods</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">AddTwoNumbers</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">and</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">MultiplyTwoNumbers</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">. The</span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">AddTwoNumbers</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">is implemented in the derived class</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">absClass2</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">. The class</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">absDerived</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">is derived from</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">absClass2</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">and the</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">MultiplyTwoNumbers</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">is implemented there.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 11.5pt 0in 6.35pt;">
<b><span style="color: #ff9900; font-family: "Segoe UI","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Abstract properties<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">Following is an
example of implementing abstract properties in a class.<o:p></o:p></span></div>
<div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg5" o:spid="_x0000_i1030" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">Collapse</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">|</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><a href="http://www.codeproject.com/Articles/6118/All-about-abstract-classes"><span style="color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//Abstract Class with
abstract properties<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">class</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> absClass<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">protected</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> myNumber;<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">public</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> numbers<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">get</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">;<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">set</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;">;<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<br /></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">class</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> absDerived:absClass<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//Implementing
abstract properties<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">public</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">override</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> numbers<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">get</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">return</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> myNumber;<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">set</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">
myNumber = value;<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></div>
</div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">In the above example,
there is a</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span lang="CS" style="color: #990000; font-family: Consolas; mso-ansi-language: CS; mso-fareast-font-family: "Times New Roman";">protected</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">member declared in the abstract class. The</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span lang="CS" style="color: #990000; font-family: Consolas; mso-ansi-language: CS; mso-fareast-font-family: "Times New Roman";">get</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">/</span><span lang="CS" style="color: #990000; font-family: Consolas; mso-ansi-language: CS; mso-fareast-font-family: "Times New Roman";">set</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">properties for the member variable</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">myNumber</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">is defined in the
derived class</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #990000; font-family: Consolas; mso-fareast-font-family: "Times New Roman";">absDerived</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 11.5pt 0in 6.35pt;">
<b><span style="color: #ff9900; font-family: "Segoe UI","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Important rules applied to abstract classes<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">An abstract class
cannot be a</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span lang="CS" style="color: #990000; font-family: Consolas; mso-ansi-language: CS; mso-fareast-font-family: "Times New Roman";">sealed</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">class. I.e. the following declaration is
incorrect.<o:p></o:p></span></div>
<div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg6" o:spid="_x0000_i1029" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">Collapse</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">|</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><a href="http://www.codeproject.com/Articles/6118/All-about-abstract-classes"><span style="color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//Incorrect<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">sealed</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">class</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> absClass<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></div>
</div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">Declaration of
abstract methods are only allowed in abstract classes.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">An abstract method
cannot be</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span lang="CS" style="color: #990000; font-family: Consolas; mso-ansi-language: CS; mso-fareast-font-family: "Times New Roman";">private</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">.<o:p></o:p></span></div>
<div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg7" o:spid="_x0000_i1028" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">Collapse</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">|</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><a href="http://www.codeproject.com/Articles/6118/All-about-abstract-classes"><span style="color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//Incorrect<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">private</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> MultiplyTwoNumbers();<o:p></o:p></span></div>
</div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">The access modifier of
the abstract method should be same in both the abstract class and its derived
class. If you declare an abstract method as</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span lang="CS" style="color: #990000; font-family: Consolas; mso-ansi-language: CS; mso-fareast-font-family: "Times New Roman";">protected</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">, it should be</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span lang="CS" style="color: #990000; font-family: Consolas; mso-ansi-language: CS; mso-fareast-font-family: "Times New Roman";">protected</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">in its derived class. Otherwise, the compiler will raise an
error.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">An abstract method
cannot have the modifier</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span lang="CS" style="color: #990000; font-family: Consolas; mso-ansi-language: CS; mso-fareast-font-family: "Times New Roman";">virtual</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">. Because an abstract method is implicitly
virtual.<o:p></o:p></span></div>
<div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg8" o:spid="_x0000_i1027" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">Collapse</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">|</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><a href="http://www.codeproject.com/Articles/6118/All-about-abstract-classes"><span style="color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//Incorrect<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">public</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">virtual</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> MultiplyTwoNumbers();<o:p></o:p></span></div>
</div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">An abstract member
cannot be</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span lang="CS" style="color: #990000; font-family: Consolas; mso-ansi-language: CS; mso-fareast-font-family: "Times New Roman";">static</span><span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">.<o:p></o:p></span></div>
<div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg9" o:spid="_x0000_i1026" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">Collapse</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">|</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><a href="http://www.codeproject.com/Articles/6118/All-about-abstract-classes"><span style="color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//Incorrect<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">publpublic </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">abstract</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">static</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> MultiplyTwoNumbers();<o:p></o:p></span></div>
</div>
<div class="MsoNormal" style="margin: 11.5pt 0in 6.35pt;">
<b><span style="color: #ff9900; font-family: "Segoe UI","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Abstract class vs. Interface<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">An abstract class can
have abstract members as well non abstract members. But in an interface all the
members are implicitly abstract and all the members of the interface must
override to its derived class.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">An example of
interface:<o:p></o:p></span></div>
<div align="right" class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: right;">
<span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes;"><v:shape alt="http://www.codeproject.com/images/minus.gif" id="preimg10" o:spid="_x0000_i1025" style="height: 6.75pt; mso-wrap-style: square; visibility: visible; width: 6.75pt;" type="#_x0000_t75">
<v:imagedata o:title="minus" src="file:///C:\Users\admin\AppData\Local\Temp\msohtmlclip1\01\clip_image003.gif">
</v:imagedata></v:shape></span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">Collapse</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="border: none windowtext 1.0pt; color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-border-alt: none windowtext 0in; mso-fareast-font-family: "Times New Roman"; padding: 0in;">|</span><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><a href="http://www.codeproject.com/Articles/6118/All-about-abstract-classes"><span style="color: purple; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Copy Code</span></a><span style="color: #005782; font-family: "Segoe UI","sans-serif"; font-size: 6.5pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div style="background: #FBEDBB; border: solid #FBEDBB 1.0pt; mso-border-alt: solid #FBEDBB .5pt; mso-element: para-border-div; padding: 3.0pt 3.0pt 3.0pt 3.0pt;">
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">interface</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> iSampleInterface<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><i><span lang="CS" style="color: green; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//All
methods are automaticall abstract<o:p></o:p></span></i></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> AddNumbers(</span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num1, </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num2);<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;"> </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> MultiplyNumbers(</span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num1, </span><span lang="CS" style="color: blue; font-family: Consolas; font-size: 9.0pt; mso-ansi-language: CS; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">int</span><span lang="CS" style="font-family: Consolas; font-size: 9pt;"> Num2);<o:p></o:p></span></div>
<div class="MsoNormal" style="background-position: initial initial; background-repeat: initial initial; border: none; margin-bottom: 0.0001pt; padding: 0in;">
<span lang="CS" style="font-family: Consolas; font-size: 9pt;">}<o:p></o:p></span></div>
</div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">Defining an abstract
class with abstract members has the same effect to defining an interface.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">The members of the
interface are public with no implementation. Abstract classes can have
protected parts, static methods, etc.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">A class can inherit
one or more interfaces, but only one abstract class.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">Abstract classes can
add more functionality without destroying the child classes that were using the
old version. In an interface, creation of additional functions will have an
effect on its child classes, due to the necessary implementation of interface
methods to classes.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #111111; font-family: "Segoe UI","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">The selection of
interface or abstract class depends on the need and design of your project. You
can make an abstract class, interface or combination of both depending on your
needs.<o:p></o:p></span></div>
<span style="font-family: "Arial","sans-serif"; font-size: 8.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;"><br clear="all" style="mso-special-character: line-break; page-break-before: always;" />
</span>
<div class="MsoNormal">
<br /></div>
</div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-42703547029345981132012-12-07T03:22:00.001-08:002012-12-07T03:22:48.258-08:00Page life cycle in asp.net<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<b><span style="font-family: Trebuchet MS, sans-serif;">General page life
cycle stages: <o:p></o:p></span></b></div>
<div class="MsoListParagraphCxSpFirst" style="mso-list: l1 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">1.<span style="font-size: 7pt;">
</span><!--[endif]-->Page Request : - The page request occur before the page life cycle
begin .</span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">2.<span style="font-size: 7pt;">
</span><!--[endif]-->Start:- In the start, page properties such as
request and response are set. At this stage , also determine whether the
request is a postback or a new
request and set’s ispostback properties .this stage also set’s the uiculture properties . </span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">3.<span style="font-size: 7pt;">
</span><!--[endif]-->Initialization’s :- During the page
initialization all controls are available and uniqueId properties of every control is set .A master page and
theme are also apply in this stage if applicable .</span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">4.<span style="font-size: 7pt;">
</span><!--[endif]-->Load :- during the load , if the current request
is postback ,control properties are set with recover
from viewstate and control state </span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">5.<span style="font-size: 7pt;">
</span><!--[endif]-->Post back event handling : - If the request is postback then control event handler are called , after the validate
method for all validator control are
called , which set’s the Isvalid
property of all validator control .</span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">6.<span style="font-size: 7pt;">
</span><!--[endif]-->Rendering:- before rendering viewstate
of page and controls are saved.
During the rendering stage page call render
method for every control of the page .</span></b></div>
<div class="MsoListParagraphCxSpLast" style="mso-list: l1 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">7.<span style="font-size: 7pt;">
</span><!--[endif]-->Unload:- the unload event call after when the
page is fully rendered ,sent to the client , and ready to discarded .</span></b></div>
<div class="MsoNormal">
<b><span style="font-family: Trebuchet MS, sans-serif;">Life cycle event:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<b><span style="font-family: Trebuchet MS, sans-serif;">Within each stage of page life cycle , the page raised some
events that you can use to run your own code .</span></b></div>
<div class="MsoListParagraph" style="mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">1.<span style="font-size: 7pt;">
</span><!--[endif]-->PreInit:- raised after the start stage has been
complete and before initialization event raised .</span></b></div>
<div class="MsoNormal" style="margin-left: .5in;">
<b><span style="font-family: Trebuchet MS, sans-serif;">Use this event for following :- </span></b></div>
<div class="MsoListParagraphCxSpFirst" style="margin-left: .75in; mso-add-space: auto; mso-list: l0 level2 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">1.1<span style="font-size: 7pt;">
</span><!--[endif]-->check is Ispostback .</span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: .75in; mso-add-space: auto; mso-list: l0 level2 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">1.2<span style="font-size: 7pt;">
</span><!--[endif]-->create or re-create dynamic controls. </span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: .75in; mso-add-space: auto; mso-list: l0 level2 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">1.3<span style="font-size: 7pt;">
</span><!--[endif]-->Set a master page dynamically .</span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-left: .75in; mso-add-space: auto; mso-list: l0 level2 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">1.4<span style="font-size: 7pt;">
</span><!--[endif]-->Set theme property </span></b></div>
<div class="MsoListParagraphCxSpLast" style="margin-left: .75in; mso-add-space: auto; mso-list: l0 level2 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">1.5<span style="font-size: 7pt;">
</span><!--[endif]-->Read or set profile property values. </span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoListParagraphCxSpFirst" style="mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">2.<span style="font-size: 7pt;">
</span><!--[endif]-->InIt:- Raised
after controls have been initialized and any skin setting has been applied .
Use this event to read or initialize control properties . </span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">3.<span style="font-size: 7pt;">
</span><!--[endif]-->Initcomplete:- Raised at the end of the page initialization
stage . Use this event to make changes to view state that you want to make sure
persisted after the next post back .</span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">4.<span style="font-size: 7pt;">
</span><!--[endif]-->Preload:- Raised after the page loads view state
for itself and all controls, and after it process post back data that is included
with the request instance .</span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">5.<span style="font-size: 7pt;">
</span><!--[endif]-->Load:-
The page object call onload method on page object . use the onload event
method to set properties in controls and establish the data base connection .</span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">6.<span style="font-size: 7pt;">
</span><!--[endif]-->Controls Event:- use this event to handle thre
specific control event , such as button click event . </span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">7.<span style="font-size: 7pt;">
</span><!--[endif]-->Load Complete :- Raised at the end of the event
handling stage .</span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">8.<span style="font-size: 7pt;">
</span><!--[endif]-->Pre Render : -Raised after the page object has
created the all control that are required in order to render the page . Use
this event to make final changes to the content of the page .</span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">9.<span style="font-size: 7pt;">
</span><!--[endif]-->Pre Render complete :- Raised after data bound
whose DataSourcdeId property set
call its databind method .</span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">10.<span style="font-size: 7pt;">
</span><!--[endif]-->Save state complete:- Raised after the </span></b></div>
<div class="MsoListParagraphCxSpLast" style="mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><b><span style="font-family: Trebuchet MS, sans-serif;">11.<span style="font-size: 7pt;">
</span><!--[endif]-->Unload: </span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<br />
</div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-54143759969668123102012-12-07T03:19:00.004-08:002012-12-07T04:11:03.440-08:00Find nth top salary in MSSQl Server Query <div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<b><span style="font-family: Trebuchet MS, sans-serif;"><span style="color: #3d85c6;">use</span> playwithjoinsbybookstore</span></b><br />
<span style="font-family: Trebuchet MS, sans-serif;"><b><br /></b>
<b><span style="color: #3d85c6;">select top</span> 1 a.salary,name <span style="color: #3d85c6;">from</span> (<span style="color: #3d85c6;">select distinct top</span> 3 salary ,name <span style="color: #3d85c6;">from</span> Tbl_Employ <span style="color: #3d85c6;">order by</span> salary<span style="color: #3d85c6;"> desc</span> ) as a <span style="color: #3d85c6;">order by</span> salary </b></span><br />
<b><span style="font-family: Trebuchet MS, sans-serif;"><br /></span></b>
<b><span style="font-family: Trebuchet MS, sans-serif;"><br /></span></b>
<b><span style="font-family: Trebuchet MS, sans-serif;">and also with aggregate function </span></b><br />
<b><span style="font-family: Trebuchet MS, sans-serif;"><br /></span></b>
<b><span style="font-family: Trebuchet MS, sans-serif;"><span style="color: #3d85c6;">select</span> <span style="color: magenta;">min</span>(salary)<span style="color: #6fa8dc;"> from</span> tbl_employ <span style="color: #3d85c6;">where</span> salary <span style="color: #3d85c6;">in</span> (<span style="color: #3d85c6;">select top</span> 5 salary<span style="color: #3d85c6;"> from</span> tbl_employ <span style="color: #3d85c6;">order by </span>salary <span style="color: #3d85c6;">desc</span> ) </span></b></div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0tag:blogger.com,1999:blog-6520202646532564438.post-26988781745592378572012-12-03T03:43:00.000-08:002012-12-03T03:43:03.600-08:00The MVC 4 improve those features<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="font-family: Trebuchet MS, sans-serif;">1. Refreshed and modernized default project templates</span></b><br />
<b><span style="font-family: Trebuchet MS, sans-serif;">2. New mobile project template </span></b><br />
<b><span style="font-family: Trebuchet MS, sans-serif;">3. Many new features to support mobile apps</span></b><br />
<b><span style="font-family: Trebuchet MS, sans-serif;">4. Recipes to customize code generation </span></b><br />
<b><span style="font-family: Trebuchet MS, sans-serif;">5. Enhanced support for asynchronous methods. </span></b><br />
<br />
<span style="font-family: Trebuchet MS, sans-serif;"> For more details, you can refer to: <a href="http://www.asp.net/mvc/mvc4">Click here</a></span></div>
Ravinder Bhawerhttp://www.blogger.com/profile/14652798846642948112noreply@blogger.com0