Book a Demo

Author Topic: C# Properties in interfaces  (Read 3114 times)

jdn4929

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
C# Properties in interfaces
« on: September 22, 2003, 10:27:00 am »
I can't figure out how to implement a C# Property in an interface. It asks me to specifiy an attribute, which is not required in C#. You could have:

public interface foo {

   Bar {
      get; set;
   }

}

and it is not associated with a specific instance variable, but it is required by the implementing class. Does anybody know how to do this?

Josh

jdn4929

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: C# Properties in interfaces
« Reply #1 on: October 02, 2003, 02:25:46 pm »
Well, I figured this out. Marking the stereotype Interface (method) as property will do this. The problem that I have now that the code it generates adds an access modifier to it (and all interface methods, by that token) which in C# is incorrect.

public String MyProperty { get; set; } //incorrect

String MyOtherProperty { get; set; } //correct


benc

  • EA Administrator
  • EA User
  • *****
  • Posts: 200
  • Karma: +0/-0
    • View Profile
Re: C# Properties in interfaces
« Reply #2 on: October 02, 2003, 05:41:48 pm »
Hi Josh,

The access modifier is a bug in the C# code generation.  Build 646 will resolve this and other issues with generating interfaces.

Build 646 should be released early next week. Thanks for the note.

Regards,
Ben