Hi All,
Could anyone please provide any link or explaination of why we create interface reference variable and assign the object of the implemented class to that(Line No.17).Here is the sample i got from msdn.
- interface ISampleInterface
- {
- void SampleMethod();
- }
- class ImplementationClass : ISampleInterface
- {
- // Explicit interface member implementation:
- void ISampleInterface.SampleMethod()
- {
- // Method implementation.
- }
- static void Main()
- {
- // Declare an interface instance.
- ISampleInterface obj = new ImplementationClass();
- // Call the member.
- obj.SampleMethod();
- }
- }
Regards
Rajeev

Rajeesh MenothPosted Jun 12, 2016, 4:04 AM