Search
Sponsor
Winners

Win Prizes

Social Presence
Twitter Twitter LinkedIn YouTube Google

Like us on Facebook
Advertisements
Top Forums Author
Mon, 24-Nov-2014 Authors
Parthibansk
20
Aadikumary
10
All Time Authors
Jayakumars
4210
Karthikanbarasan
3455
Chvrsri
3140

Latest members | More ...


(Statistics delayed by 5 minutes)
 Forum Post

creating an object for interface

Priyajagan
Posted by Priyajagan under .NET Certifications on 7/26/2011 7:51:51 AM | Points: 10 | Views : 2027 | Status : [Member] | Replies : 2


Can we create an object for an interface? How?



Posted by: Jpchoudhari on: 7/26/2011 [Member] Starter | Points: 25

Hi,

You can not create object of Interface type as it contains only declination or implementation behavior.

Refer this:
http://msdn.microsoft.com/en-us/library/87d83y5b(v=VS.100).aspx
http://www.codeproject.com/KB/cs/cs_interfaces.aspx

Kind Regards,
Jay

Priyajagan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kadhababu on: 7/27/2011 [Member] Starter | Points: 25

You can't create an object without method implementations. Anonymous inner classes allow you to do the following, though:

view plaincopy to clipboardprint?

public interface MyInterface {
public void myMethod() ;
}

...

MyInterface myIntfObj = new MyInterface() {
public void myMethod() {
....
}
};

myIntfObj.myMethod();


http://www.cegonsoft.com/dotnet.phpDot Net Training

Priyajagan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response


Found interesting? Add this to: