|
-
readonly properties in an interface show up as get_PropertyName method
I've defined an interface called IDevice.
public interface IDevice
{
string DeviceLabel {get; set;}
string HostName {get; }
string TCPAddress {get; }
string MACAddress {get; }
bool Online {get; set;}
int CheckInsMissed {get; set;}
long TimeInterval {get; set;}
DateTime CheckInTime {get; set;}
}
You'll notice that three of the properties are read-only (Only a get accessor
is specified).
I've implemented this interface in a class called Device.
In my client code I create a new device but only access it through the IDevice
interface.
public class Device : IDevice
{
// not all code shown
public string HostName
{
get
{
return _hostName;
}
}
public string TCPAddress
{
get
{
return _tcpAddress;
}
}
}
An example of client code:
IDevice myDevice = new Device('constructor parameters);
Here is the problem. My readonly properties don't show up. Instead only
the accessor methods show up.
Here is more detail. If I use the object browser to examine IDevice I see
all my properties. If I use the object browser to examine the Device class
I see all my properties. If I drill down into Bases and Interfaces for the
Device class and view IDevice my readonly properties don't show up, instead
I see the get methods in there place. So I get a compile time errors when
I try to access my readonly properties through IDevice. The message tells
me to use the get accessors directly.
What have I done wrong in my defintions?
Thanks,
Michael
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks