What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 53258 |  Welcome, Guest!   Register  Login
 Home > Forums > .NET Certifications > creating an object for interface ...
Priyajagan

creating an object for interface

Replies: 2 | Posted by: Priyajagan on 7/26/2011 | Category: .NET Certifications Forums | Views: 1087 | Status: [Member] | Points: 10  


Can we create an object for an interface? How?


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Jpchoudhari
Jpchoudhari  
Posted on: 7/26/2011 7:58:52 AM
Level: Starter | Status: [Member] | 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. | Reply | Alert Moderator 

Kadhababu
Kadhababu  
Posted on: 7/27/2011 1:25:29 AM
Level: Starter | Status: [Member] | 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. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/23/2013 7:48:36 AM