Reputation: 22074
I have a VB.Net structure defined like this:-
Public Structure MyStructure
Public Property MyProperty () As String
Get
Return "" ' Return something
End Get
Set
' Do something
End Set
End Property
Public Property MyProperty (Byval my_parameter As String) As String
Get
Return "" ' Return something
End Get
Set
' Do something
End Set
End Property
End Structure
and I am attempting to invoke these properties from some C# code. I am able to invoke the overload with a parameter like this:-
MyStructure the_structure = New MyStructure ();
the_structure.set_MyProperty ("Hello", "World");
but attempting to use the parameterless version like this:-
the_structure.set_MyProperty ("Hello");
results in a compilation error:-
No overload for method 'set_MyProperty' takes 1 arguments
A similar result occurs with the get:-
string string1 = the_structure.get_MyProperty("Hello"); // Fine
string string2 = the_structure.get_MyProperty(); // Compilation error
Does anyone know how I should invoke the parameterless property?
Upvotes: 1
Views: 100
Reputation: 46967
The normal way should work.
string string2 = the_structure.MyProperty;
Upvotes: 1