IT Community - Software Programming, Web Development and Technical Support

c# interface

This is a discussion on c# interface within the C# Programming forums, part of the Software Development category; Can anybody explain me about the concept of Interface and its advantages in C#.net?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 09-01-2007, 08:08 AM
Sathish Kumar Sathish Kumar is offline
D-Web Analyst
 
Join Date: Feb 2007
Posts: 304
Sathish Kumar is on a distinguished road
Exclamation c# interface

Can anybody explain me about the concept of Interface and its advantages in C#.net?
__________________
Sathish Kumar.R
Knowledge is meant to SHARE
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-02-2007, 11:28 PM
smani smani is offline
D-Web Programmer
 
Join Date: Aug 2007
Posts: 56
smani is on a distinguished road
Default Re: c# interface

hi,

Interface is used to rectify the drawback of multiple inheritance, the creators of C# have introduced a new concept called interfaces. Java programmers may be well aware of this concept. All interfaces should be declared with the keyword interface. You can implement any number of interfaces in a single derived class, but you should provide signatures to all method definitions of the corresponding interfaces.

Advantages:
1.This construct makes the software flexible for future changes.
2.The client using your class through a method argument or instance variable will not have to know anything about the class
3.The chance of failures, faults or errors getting thrown when you make changes to existing code will be lower when the classes are decoupled.

Regards
Manivannan.s
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-02-2007, 11:32 PM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Re: c# interface

hi

Interfaces in C# are provided as a replacement of multiple inheritance. Because C# does not support multiple inheritance, it was necessary to incorporate some other method so that the class can inherit the behavior of more than one class, avoiding the problem of name ambiguity that is found in C++. With name ambiguity, the object of a class does not know which method to call if the two base classes of that class object contain the same named method.

The classes in C# can now make use of the keyword "interface" to inherit more than one behavior from different interfaces. When a class inherits from one or more interfaces, we say that the class is implementing that interface(s). The most important thing to remember about interfaces is that the classes can only implement the methods defined in the interface because in C#, an interface is a built-in keyword that declares a reference type that includes method declarations. In addition to methods, interfaces can define properties, indexers, and events

uses:
1. To allow a class to inherit multiple behaviors from multiple interfaces.
2. To avoid name ambiguity between the methods of the different classes as was in the use of multiple inheritance in C++.
3. To combine two or more interfaces such that a class need only implement the combined result.
4. To allow Name hiding. Name hiding is the ability to hide an inherited member name from any code outside the derived class.
__________________
The KINGMAKER
Makes Every Thing Possible

Stuffs (My Blog)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the use of interface? Mramesh C# Programming 5 02-08-2008 04:51 AM
What is the Servlet Interface? Arun Java Programming 2 09-10-2007 04:35 AM
What is the Set interface? anbuchezhians Java Programming 4 09-10-2007 04:18 AM
Map interface in Collection Api leoraja8 Java Programming 6 09-06-2007 03:51 AM
Do we have interface to schedule a task like ITaskscheduler interface for desktop.... theone Mobile Software Development 1 07-24-2007 11:29 PM


All times are GMT -7. The time now is 11:07 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0