Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parameterized property

Status
Not open for further replies.

need2progm

Programmer
Dec 13, 2002
92
US
I have parameterized property written in VB.NET. How do I use that in C#?

In VB…
public property A( B as B) as C

In C#......
C = A( ??? ) ;

I thought this.. c = A; but nope.. didn’t work


Thanks for any direction you can give me…
 
You can't do that in C#. See:

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/csspec/html/vclrfcsharpspec_10_6.htm

The language spec basically says that a property consists of:
[tab]Attributes(optional)
[tab]Property-Modifiers(optional)
[tab]Type
[tab]Member-Name
[tab]Accessor-declaraions

Where:
[ol][li]Attributes is your typical .NET attributes (serializable, etc)[/li]
[li]Property-Modifiers is the scope, etc. (public, protected, static, override, etc)[/li]
[li]Type is one of the .NET types or a derived type[/li]
[li]Member-Name is the name of your property[/li]
[li]Accessor-declarations is the get & set statements, with their code blocks[/li][/ol]So, no extra parameters can be passed.

I think what you're asking for would be called a function.
:)

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Actually .. you can in around about way .. I have written parameterized properties in c# but that really wasn't my question.

I have a soultion that contains a vb proj and a c# proj. I want to use one of the parameterized properties in the vb project in the C# code.

This is what I came up with.

vb project code...
Public Property message(ByVal ndx As Int32) As String
Get
blah blah blah
End Get

Set(ByVal Value As String)
blah blah blah
End Set
End Property


In C# Project code...

//the set_that VB wrote for the property takes 2 arguments - the "index" and the value

//object that exposes the property in VB
private VBCode.PropClass pc = new PropClass();
pc.set_message( ndx, txtPropertyValue.Text );


I must give credit where credit is due... Thanks Kevin :)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top