473,385 Members | 1,449 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,385 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 15909
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 instance should use the same bitmap (so I'm thinking...
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 static INullObject Null { get { return...
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 in real life. The basic problem is that when a...
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 PropertyGrid to edit static properties ? Thank's
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 it "possible" to have each session "not"...
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 to the concepts i'd like to ask if what i'm about...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.