readonly properties in an interface show up as get_PropertyName method


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: readonly properties in an interface show up as get_PropertyName method

  1. #1
    Michael Welch Guest

    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

  2. #2
    Michael Welch Guest

    Re: readonly properties in an interface show up as get_PropertyName method


    >Here is the problem. My readonly properties don't show up. Instead only
    >the accessor methods show up.
    >


    Nevermind. This is the third problem I've posted to this newsgroup, that
    must be a result of something funky on my machine.

    I rebuilt the project that contained my interface and everything is fine
    now. This is a great learning tool (made me review everything about interfaces
    again), but its starting to waste a significant amount of time.

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center