C# .NET - interface implementation in c# web application
Asked By hiral jani
04-Feb-12 01:38 AM
Hello,
I have 1 web application in c#.
I want to use interface for the same for some inheritance purpose.
Kindly give some suggestion along with some code / link for the same.
I want it for web application not console application.
Suchit shah replied to hiral jani
Interface is a pure abstract entity:
- It contains only the declaration.
- We cannot make instance of an Interface. We must inherit to use Interface.
- A class which implements the interface should implement all the members of an Interface.
- Members of an Interface are always public.
Example of Interface
interface ISampleInterface1
{
void SampleMethod1();
}
interface ISampleInterface2
{
void SampleMethod2();
}
class ImplementationClass : ISampleInterface1, ISampleInterface2
{
// Explicit interface member implementation:
void ISampleInterface1.SampleMethod1() { // Method implementation.
void ISampleInterface2.SampleMethod2() { // Method implementation.
}
static void Main()
{
// Declare an interface instance.
ISampleInterface1 obj = new ImplementationClass();
// Call the member.
obj.SampleMethod1();
}
}
In this way you can be able to implement the Interface for the Inheritance

use of undefined type 'main' C++ / VB I have two classes(class A, class main). class main uses a pointer to class A and class A uses a global pointer to main. My problem is I keep
C'tor vs. function declaration C++ / VB Consider an example: struct S { S( int ) {} }; class C { public: C() {} C( int ) {} C( S ) {} int get_int() { return 0; } }; int main() { C obj0; int i = 0; C obj1( S( obj0.get_int() ) ); / / (1) c'tor C( int
Syntax for friend template classes? C++ / VB I have a template class and want to declare another template class (of the same shape) as a friend. This seems to work: template<class C> class bar; / / forward declare template<class C> class foo { friend class bar<C> ; }; but it is annoying that I have to forward
True infinite loop in variadic template instantiation (under g++4.6.1) C++ / VB Consider the following program: template<class C> class loop1 { public: typedef typename loop1<loop1<C> > ::RET RET; }; template<class. . . C> class loop2 { public: typedef typename loop2<C. . ., loop2<C. . .> > ::RET RET; }; / / typedef loop1<int> ::RET RET1
Can generic types be overloaded? .NET Framework Hi, [Section 20.1 The C# Programming Language;Anders Hejlsberg, Scott Wiltamuth, Peter Golde] Generic types may not be "overloaded"; that type must be uniquely named within a scope in the same way as ordinary types. class C {} class C<V> {} / / Error, C defined twice class C<U, V> {} / / Error, C defined twice But I was unable to verify this using Microsoft