Interface using in ASP.NET
Anybody can give me sample code or demo project of interface use in asp.net .
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Felipe RamosPosted Jun 30, 2011, 8:23 AM
public interface IExport
{
void Export();
}
public class ExcelExporter : IExport
{
public void Export()
{
}
}
public class HtmlExporter : IExport
{
public void Export()
{
}
}
If you had code that that works like this
public IExport GetExporter(ExportFormat format)
{
switch (format)
{
case ExportFormat.Excel:
return new ExcelExporter();
}
}
Than you can say
GetExporter(ExportFormat.Excel).Export(); and be sure that any class that implemented IExport will be exposing an Export function.
bhahanan yPosted Jun 30, 2011, 7:50 AM
Posted Jun 30, 2011, 7:36 AM