How to expose properties in COM interop

P

Prigozhin Roman

Hi , I have a COM object implemented in C#
Problem is that my properties ( which defined public in the class ) can not
be seen from the outside ( When I call COM )
I can see only functions I defined in class interface.
If I try to define variables there I get an error : Interfaces can not
contain variables ( which is understandable ).
Question. How to expose variables.

Thanks,
Roman Prigozhin
P.S
If you want to suggest implement set and get functions to do that , please
don't bother, it is an obvious solution.
I want to know the other way of doing it through definitions.
 
N

Nicholas Paldino [.NET/C# MVP]

Prigozhin,

When declaring your interface, you can just do this:

public interface IMyInterface
{
string MyProperty {get; set;}
}

You can choose to omit either get or set to get write-only or read-only
functionality.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top