PROGRAM 1:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Interface
{
class Program : abc
{
static void Main(string[] args)
{
Console.WriteLine("Hello interfaces");
Program p = new Program();
p.xyz();
}
public void xyz()
{
Console.WriteLine("In xyz");
}
}
interface abc
{
void xyz();
}
}
OUTPUT:
Hello interfaces
In xyz
INPUT:
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Interface
{
class Program : abc
{
static void Main(string[] args)
{
Console.WriteLine("Hello interfaces");
Program p = new Program();
p.xyz();
}
public void xyz()
{
Console.WriteLine("In xyz");
}
}
interface abc
{
void xyz();
}
}
OUTPUT:
Hello interfaces
In xyz
INPUT:
PROGRAM 2:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Interface
{
class ClassA : abc
{
static void Main(string[] args)
{
Console.WriteLine("Hello interfaces\n");
ClassA p = new ClassA();
ClassB q = new ClassB();
p.xyz();
q.xyz();
}
public void xyz()
{
Console.WriteLine("In ClassA:xyz\n");
}
}
interface abc
{
void xyz();
}
class ClassB : abc
{
public void xyz()
{
Console.WriteLine("In ClassB:xyz\n");
}
}
}
OUTPUT:
Hello Interfaces
In ClassA:xyz
InClassB:xyz
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Interface
{
class ClassA : abc
{
static void Main(string[] args)
{
Console.WriteLine("Hello interfaces\n");
ClassA p = new ClassA();
ClassB q = new ClassB();
p.xyz();
q.xyz();
}
public void xyz()
{
Console.WriteLine("In ClassA:xyz\n");
}
}
interface abc
{
void xyz();
}
class ClassB : abc
{
public void xyz()
{
Console.WriteLine("In ClassB:xyz\n");
}
}
}
OUTPUT:
Hello Interfaces
In ClassA:xyz
InClassB:xyz
Hey, you should take a look at the Naming Guidelines section in the Design Guidelines for Developing Class Libraries on MSDN (direct link: http://msdn.microsoft.com/en-us/library/ms229002.aspx). You should try to follow these guidelines as closely as possible to ensure that other .NET developers can easily understand your code.
ReplyDeleteSpecifically, interface names should begin with a capital "I" and public names in general should be in camel case. For example, in this case, the interface name should be IXyz.