ankitweblogic logo
W e b t u t o r i a l s

Visual Studio.NET IDE

Define C#.NET

C# Comment

C# Variables

C# Data Types

C# Escape Sequence

C# Operators

Exercise-1

Format String

Operator Precedence

C# Keywords

Constant Variable

Type Conversion

Flow Control

Exercise Loops & Nested Loop

C# Arrays

C# Strings

User-Define Methods

Variable Scope

C# Enumerations

C# Structure

C# Exception Handling

Object Oriented Programming

C# Classes

Constructor & Destructor

C# Inheritance

C# Polymorphism

C# Operator Overloading

C# Interface

Abstract Classes & Methods

Sealed Classes, Methods

C# Properties

C# Indexer

C# Delegates

C# Generics

C# Collection

System.Object

C#.Net Interface

Interfaces are declared in a same way as classes, but with the keyword interface. Interface can’t be instantiated as a class. Interface can’t contain any code that implements its member. A class can support multiple interface and multiple classes can support the same interface. If a class implements an interface it has to define all its members otherwise class has to be declared abstract.

Interface IMyInterface
{
	// interface members
}

The keyword abstract and sealed is not applicable with interface. Interface inheritance is also possible like class inheritance.

public interface IMyInterface :IMyBaseInterface, IMyBaseInterface2
{
	// interface members
}
interface circle
{
	float area(float r);
}
class example : circle
{
	public float area(float r)
	{
		float a = 3.14f * r * r;
		return a;
	}
}
class Program
{
	static void Main(string[] args)
	{
		example ex = new example();
		circle cir=ex;
		float f = cir.area(5.0f);
		Console.WriteLine(f);
		Console.Read();
	}
}