469,927 Members | 1,768 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

Interface and static properties

I have looked through the documents but could not find
any information on this. Is anything like static properties
in interfaces?

If not, how do I define property in interface to be made
static property in an abstract base class implementing
the property?

The problem is, I have a lot of interfaces in a library project and
will wish most uses of the library classes should be through
these interfaces and also access to static fields
in the interface. Java allows static fields in interfaces but
..NET does and I was trying to see if property could help.
Any idea?

Best regards,
Paul.

Nov 15 '05 #1
2 15583
Paul,

You can not add members to an interface. Also, interfaces do not
support static properties, as interfaces are limited to the instance, not to
the type itself.

I would recommend using an abstract class if you want to do this,
instead of using an interface.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Paul Selormey" <pa**@toolscenter.org> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have looked through the documents but could not find
any information on this. Is anything like static properties
in interfaces?

If not, how do I define property in interface to be made
static property in an abstract base class implementing
the property?

The problem is, I have a lot of interfaces in a library project and
will wish most uses of the library classes should be through
these interfaces and also access to static fields
in the interface. Java allows static fields in interfaces but
.NET does and I was trying to see if property could help.
Any idea?

Best regards,
Paul.

Nov 15 '05 #2
Hello Nicholas,
Thanks for the response. I was hoping there is some
trick or work around the problem, so that I will not
have to force use of abstract classes here and there.

Again, thanks for the information.
Best regards,
Paul.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
Paul,

You can not add members to an interface. Also, interfaces do not
support static properties, as interfaces are limited to the instance, not to the type itself.

I would recommend using an abstract class if you want to do this,
instead of using an interface.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Paul Selormey" <pa**@toolscenter.org> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have looked through the documents but could not find
any information on this. Is anything like static properties
in interfaces?

If not, how do I define property in interface to be made
static property in an abstract base class implementing
the property?

The problem is, I have a lot of interfaces in a library project and
will wish most uses of the library classes should be through
these interfaces and also access to static fields
in the interface. Java allows static fields in interfaces but
.NET does and I was trying to see if property could help.
Any idea?

Best regards,
Paul.



Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Maria Gaitani | last post: by
reply views Thread by Steve Rosenberry | last post: by
5 posts views Thread by TruongLapVi | last post: by
4 posts views Thread by Mantorok | last post: by
5 posts views Thread by =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.