473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

why interface methods are public by default

A c# design question - why interface methods are designed to be implicitly
public (that is, no access specifier) - for allowing flexibility to the
classes implementing the interface?
--
Thanks,
Sameeksha
MCAD.Net
Jul 10 '07 #1
4 5058
Hi Sameeksha,

Because it's a class contract (for class-external data exchanging, exposing
certain implementation and such) and should be visible. Why do you need the
private methods for it? A (abstract) classes are used to contain public and
hiden implementation (coz they are base for further implementation).

Regards, Alex Meleta
[TechBlog] http://devkids.blogspot.com

SA c# design question - why interface methods are designed to be
Simplicitly public (that is, no access specifier) - for allowing
Sflexibility to the classes implementing the interface?
S>
Jul 10 '07 #2
On Jul 10, 8:32 am, Sameeksha <Sameek...@discussions.microsoft.com>
wrote:
A c# design question - why interface methods are designed to be implicitly
public (that is, no access specifier) - for allowing flexibility to the
classes implementing the interface?
--
Thanks,
Sameeksha
MCAD.Net
Hi Sameeksha,
If your class implements an interface, you are implicitly agreeing
that your class supports the interface in its entirety. It does not
make sense to implement an interface and then hide some of the members
as "private" for example. Consider the problem from a client's
perspective... if you get an object and you find that it implements a
certain interface, you want to be able to call methods/properties on
that interface without first checking to see if each one is "public".

Hope this helps,
John

Jul 10 '07 #3
Hello Sameeksha,

Such a C# language design, to support only public interfaces.
Albeit in other languages interfaces can be private http://en.wikipedia.org/wiki/Interfa...ter_science%29

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

SA c# design question - why interface methods are designed to be
Simplicitly public (that is, no access specifier) - for allowing
Sflexibility to the classes implementing the interface?
S>
Jul 10 '07 #4
On Jul 10, 1:43 pm, Alex Meleta <amel...@gmail.comwrote:
Because it's a class contract (for class-external data exchanging, exposing
certain implementation and such) and should be visible. Why do you need the
private methods for it? A (abstract) classes are used to contain public and
hiden implementation (coz they are base for further implementation).
There are levels between private and public though... it's far from
uncommon to have an internal interface which would be nicely
implemented with internal methods...

Jon

Jul 10 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Roy Pereira | last post by:
I have an application that is composed of a set of "Content" dlls and a viewer application. The viewer calls a standard set of functions that are present in all the dlls. I maintain this by...
8
by: He Shiming | last post by:
Hi, I've developed a class that implements an interface definition. It looks like this: class IRecord { public: // define interface methods by pure virtual methods // no member variables }
2
by: PatrickSA | last post by:
Hi, Am new to web services, so apologies for the basic nature of the question - and apologies in advance if this is the wrong newsgroup. We're building a new web service and I'm looking around...
4
by: jm | last post by:
Consider: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconwhenshouldiimplementinterfacesinmycomponent.asp // Code for the IAccount interface module. public...
6
by: Alex Sedow | last post by:
Example 1 interface I { string ToString(); } public class C : I { public void f() {
20
by: Ole Hanson | last post by:
I am accessing my database through an interface, to allow future substitution of the physical datastore - hence I would like to declare in my Interface that my DAL-objects implementing the...
14
by: Laurent Vigne | last post by:
Hello, I would like to know how to make the methods of an interface inaccessible from outside Example: ---------------------------------------------- internal Interface ImyInterface { void...
6
by: Ricky W. Hunt | last post by:
It's dawning on my a lot of my problems with VB.NET is I'm still approaching it in the same way I've programmed since the late 70's. I've always been very structured, flow-charted everything, used...
12
by: masoud bayan | last post by:
I've come across something in Interface implementation that I am not sure is correct behavior in VB.NET (and maybe C#) or not? Consider following example: Public Interface IShape
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.