VB.NET Class Properties

P

Paul Wu

Perhaps someone can enlighten me with a peculiar question I have:

Why is that in a Class library written in VB.NET, a public property can be
accessed through "Class.Property" notation when consumed by a VB.NET
application. However, when consuming such Class library from a C# app, the
property must be accessed using "Class.Get_Property" or "Class.Set_Property"
notation. Whereas if I code the Class library in C#, I can access the same
property using Class.Property notation.

May I doing something wrong?

Thanks in advance,
Paul Wu
 
K

Kalpesh

Hi Paul,

It works as expected
Either ways it shows property name & NOT set_property & get_property

Could you post your code to demonstrate ?
Also, which ver of VS.net are you using ?

Kalpesh
 
H

Herfried K. Wagner [MVP]

Paul Wu said:
Why is that in a Class library written in VB.NET, a public property can be
accessed through "Class.Property" notation when consumed by a VB.NET
application. However, when consuming such Class library from a C# app, the
property must be accessed using "Class.Get_Property" or
"Class.Set_Property" notation. Whereas if I code the Class library in C#,
I can access the same property using Class.Property notation.

Properties can be accessed without specifying 'get_' and 'set_' prefixes in
both, VB.NET and C#. Note that C# is case-sensitive, so you'll have to type
the property's name exactly as it is spelled in the VB.NET class library.
If this doesn't solve the problem, I suggest to post some test code which
doesn't work.
 

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