ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2017 www.aspforums.com. All rights reserved.Example of Interface and Abstract class in real project using C# in ASP.NetHi @iammann,<br />Please try the following<br /><br /><a href = 'link(Threads/112777/Why-do-we-use-Interface-instead-of-Abstract-class-in-C-Net/)'>Why do we use Interface instead of Abstract class in C# .Net</a><br /><br />It might help you.<br /><br />Cheers Andrea.http://www.aspforums.net/Threads/959497/Example-of-Interface-and-Abstract-class-in-real-project-using-C-in-ASPNet/http://www.aspforums.net/Threads/959497/Example-of-Interface-and-Abstract-class-in-real-project-using-C-in-ASPNet/Thu, 05 Jan 2017 10:05:13 GMTExample of Interface and Abstract class in real project using C# in ASP.Net<p>Refer:</p> <ol class="addToReplyList"> <li><input name="threadId" type="hidden" value="410867" /><a class="threadTitle" href="http://www.aspforums.net/Threads/410867/Implement-interface-in-aspnet-with-c-live-example/">Implement <span class="Highlight">interface</span> in asp.net with c# live example </a></li> <li><input name="threadId" type="hidden" value="603301" /><a class="threadTitle" href="http://www.aspforums.net/Threads/603301/When-to-use-Abstract-Class-And-Interface-In-C/">When to use Abstract Class And <span class="Highlight">Interface</span> In C# </a></li> </ol>http://www.aspforums.net/Threads/959497/Example-of-Interface-and-Abstract-class-in-real-project-using-C-in-ASPNet/http://www.aspforums.net/Threads/959497/Example-of-Interface-and-Abstract-class-in-real-project-using-C-in-ASPNet/Fri, 06 Jan 2017 02:42:53 GMTExample of Interface and Abstract class in real project using C# in ASP.Net<p>i have already seen your references.but i have no idea how to implement these in my projects which i am making.can you give any examle.which are used in live projects.like any crued operation or any type of method or function which are used by making interface.</p>http://www.aspforums.net/Threads/959497/Example-of-Interface-and-Abstract-class-in-real-project-using-C-in-ASPNet/http://www.aspforums.net/Threads/959497/Example-of-Interface-and-Abstract-class-in-real-project-using-C-in-ASPNet/Fri, 06 Jan 2017 05:09:13 GMTExample of Interface and Abstract class in real project using C# in ASP.Net<p>Hi <a class="username" rel="iammann"> iammann</a>,</p> <p>Here is a small sample that you can understood the concept.</p> <p><span style="text-decoration: underline;">HTML</span></p> <pre class="brush: html">&lt;div&gt; &lt;table border=&#34;0&#34; cellpadding=&#34;0&#34; cellspacing=&#34;0&#34;&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:GridView ID=&#34;gvEmployees&#34; runat=&#34;server&#34; Caption=&#34;&lt;b&gt;Interface&lt;/b&gt;&#34; /&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:GridView ID=&#34;gvCustomers&#34; runat=&#34;server&#34; Caption=&#34;&lt;b&gt;Abstract&lt;/b&gt;&#34; /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt;</pre> <p>For interface create a property class with the name Employees</p> <pre class="brush: csharp">/// &lt;summary&gt; /// Employees get set property. /// &lt;/summary&gt; public class Employees { public string EmployeeId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } }</pre> <p>Then create interface IEmployee</p> <pre class="brush: csharp">/// &lt;summary&gt; /// interface IEmployee. /// &lt;/summary&gt; public interface IEmployee { /// &lt;summary&gt; /// Get list of Employees. /// &lt;/summary&gt; /// &lt;returns&gt;List of Employees&lt;/returns&gt; List&lt;Employees&gt; PopulateEmployees(); }</pre> <p>Then create class Employee which inherit interface.</p> <pre class="brush: csharp">/// &lt;summary&gt; /// Employee Class inherits IEmployee interface. /// &lt;/summary&gt; public class Employee : IEmployee { /// &lt;summary&gt; /// Get list of Employees. /// &lt;/summary&gt; /// &lt;returns&gt;List of Employees&lt;/returns&gt; public List&lt;Employees&gt; PopulateEmployees() { string strConnString = ConfigurationManager.ConnectionStrings[&#34;constr&#34;].ConnectionString; SqlConnection con = new SqlConnection(strConnString); string query = &#34;SELECT TOP 10 [EmployeeID],[LastName],[FirstName] FROM [Employees]&#34;; SqlCommand cmd = new SqlCommand(query); SqlDataAdapter sda = new SqlDataAdapter(cmd); cmd.Connection = con; DataTable dt = new DataTable(); sda.Fill(dt); List&lt;Employees&gt; employees = new List&lt;Employees&gt;(); foreach (DataRow row in dt.Rows) { employees.Add(new Employees { EmployeeId = row[&#34;EmployeeId&#34;].ToString(), FirstName = row[&#34;FirstName&#34;].ToString(), LastName = row[&#34;LastName&#34;].ToString() }); } return employees; } }</pre> <p>For abstract same way create class with the name Customer</p> <pre class="brush: csharp">/// &lt;summary&gt; /// Summary description for Customer /// &lt;/summary&gt; public abstract class Customer { /// &lt;summary&gt; /// Gets List of Customers. /// &lt;/summary&gt; /// &lt;returns&gt;List of Customers.&lt;/returns&gt; abstract public DataTable PopulateCustomers(); }</pre> <p>Create Customers class that override Customer abstract class.</p> <pre class="brush: csharp">/// &lt;summary&gt; /// Summary description for Customers /// &lt;/summary&gt; public class Customers : Customer { /// &lt;summary&gt; /// Override PopulateCustomers. /// &lt;/summary&gt; public override DataTable PopulateCustomers() { string strConnString = ConfigurationManager.ConnectionStrings[&#34;constr&#34;].ConnectionString; SqlConnection con = new SqlConnection(strConnString); string query = &#34;SELECT TOP 10 [CustomerID],[ContactName],[City],[Country] FROM [Customers]&#34;; SqlCommand cmd = new SqlCommand(query); SqlDataAdapter sda = new SqlDataAdapter(cmd); cmd.Connection = con; DataTable dt = new DataTable(); sda.Fill(dt); return dt; } }</pre> <p>After running the above below is the output.</p> <table border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td> <div> <table id="gvEmployees" style="border-collapse: collapse;" border="1" rules="all" cellspacing="0"><caption><strong>Interface</strong></caption> <tbody> <tr><th scope="col">EmployeeId</th><th scope="col">FirstName</th><th scope="col">LastName</th></tr> <tr> <td>1</td> <td>Nancy</td> <td>Davolio</td> </tr> <tr> <td>2</td> <td>Andrew</td> <td>Fuller</td> </tr> <tr> <td>3</td> <td>Janet</td> <td>Leverling</td> </tr> <tr> <td>4</td> <td>Margaret</td> <td>Peacock</td> </tr> <tr> <td>5</td> <td>Steven</td> <td>Buchanan</td> </tr> <tr> <td>6</td> <td>Michael</td> <td>Suyama</td> </tr> <tr> <td>7</td> <td>Robert</td> <td>King</td> </tr> <tr> <td>8</td> <td>Laura</td> <td>Callahan</td> </tr> <tr> <td>9</td> <td>Anne</td> <td>Dodsworth</td> </tr> <tr> <td>18</td> <td>Shashikant</td> <td>Moria</td> </tr> </tbody> </table> </div> </td> <td> <div> <table id="gvCustomers" style="border-collapse: collapse;" border="1" rules="all" cellspacing="0"><caption><strong>Abstract</strong></caption> <tbody> <tr><th scope="col">CustomerID</th><th scope="col">ContactName</th><th scope="col">City</th><th scope="col">Country</th></tr> <tr> <td>AAFKM</td> <td>Mudassar Khan</td> <td>Warszawa</td> <td>Belgium</td> </tr> <tr> <td>ALFKI</td> <td>Maria</td> <td>Boise</td> <td>Austria</td> </tr> <tr> <td>ANATR</td> <td>Ana Trujillo</td> <td>M&eacute;xico D.F.</td> <td>France</td> </tr> <tr> <td>ANTON</td> <td>Antonio Moreno</td> <td>Montr&eacute;al</td> <td>Brazil</td> </tr> <tr> <td>AROUT</td> <td>Thomas Hardy</td> <td>Mannheim</td> <td>Ireland</td> </tr> <tr> <td>BERGS</td> <td>Christina Berglund</td> <td>Lule&aring;</td> <td>Italy</td> </tr> <tr> <td>BLAUS</td> <td>Hanna Moos</td> <td>Mannheim</td> <td>Finland</td> </tr> <tr> <td>BLONP</td> <td>Fr&eacute;d&eacute;rique Citeaux</td> <td>Strasbourg</td> <td>Finland</td> </tr> <tr> <td>BOLID</td> <td>Mart&iacute;n Sommer</td> <td>Madrid</td> <td>Argentina</td> </tr> <tr> <td>BONAP</td> <td>Laurence Lebihan</td> <td>Marseille</td> <td>USA</td> </tr> </tbody> </table> </div> </td> </tr> </tbody> </table>http://www.aspforums.net/Threads/959497/Example-of-Interface-and-Abstract-class-in-real-project-using-C-in-ASPNet/http://www.aspforums.net/Threads/959497/Example-of-Interface-and-Abstract-class-in-real-project-using-C-in-ASPNet/Fri, 06 Jan 2017 10:05:57 GMTExample of Interface and Abstract class in real project using C# in ASP.Net<p>Dear,</p> <p>The choice of whether to design your functionality as an interface or an abstract class (a&nbsp;<strong>MustInherit</strong>&nbsp;class in Visual Basic) can sometimes be a difficult one. An&nbsp;<em>abstract class</em>&nbsp;is a class that cannot be instantiated, but must be inherited from. An abstract class may be fully implemented, but is more usually partially implemented or not implemented at all, thereby encapsulating common functionality for inherited classes.</p>http://www.aspforums.net/Threads/959497/Example-of-Interface-and-Abstract-class-in-real-project-using-C-in-ASPNet/http://www.aspforums.net/Threads/959497/Example-of-Interface-and-Abstract-class-in-real-project-using-C-in-ASPNet/Fri, 06 Jan 2017 10:43:12 GMT