472,353 Members | 2,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 15839
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Maria Gaitani | last post by:
Hi! I am trying to programme some java native interface but I'm still in the process of research. I've seen examples such as this one...
0
by: Steve Rosenberry | last post by:
I have a class that inherits from System.Windows.Forms.Label. The background image for my class is drawn using a bitmap as a template. Every...
5
by: TruongLapVi | last post by:
Hi, Why C# does not support Interface static member ? Some time I want implement NullObject Pattern: public interface INullObject { public...
3
by: Ryan Steckler | last post by:
I found this behavior while trying to implement a singleton class. Below is a somewhat more straight forward example, though admittedly less useful...
2
by: Polo | last post by:
Hi, I have a class (in 1.1 NET) that defines static properties. Thes class doen'st have public constructor. How can I connect this class to the...
4
by: Mantorok | last post by:
Hi I have an ASP app which references a few static properties in some of the classes. I understand that you should use Session variables, but is...
5
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post by:
I've been playing with using static properties using a simple example and i see the potential for some site performance boosts. As i'm a little new...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.