Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: jdn4929 on September 22, 2003, 10:27:00 am

Title: C# Properties in interfaces
Post by: jdn4929 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
Title: Re: C# Properties in interfaces
Post by: jdn4929 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

Title: Re: C# Properties in interfaces
Post by: benc 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