473,480 Members | 2268 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Property me()

hello,
in C# you can define a property like this: public object this [string key]
So you can acess a IDictonary member by the instance that holds the hash or
what ever.. I try to get it in vb but I cant find the way. Public Property
me(ByVal key As String) As Object doesnt work like this in C# for the
property. So how is the correct syntax for that issue?

Dont work:

Public Property me(ByVal key As String) As Object
Get
If (_data.ContainsKey(key)) Then
Return _data(key)
Else
Return Nothing
End If
End Get
Set(ByVal value As Object)
SetValue(key, value)
End Set
End Property

Thanks a lot!

--
Holger Kreissl
..NET Software Developer
http://kreissl.blogspot.com/

Jun 27 '08 #1
3 1194
OK I found that it should work like this:

class ClassName
Public Property ClassName(ByVal key As String) As Object
...

But i still get the message "cannot be indexed because it has no default
property"... But i have defined the default property or is there something
more to define?

ty
Jun 27 '08 #2
Define it like this:

Default Public Property Item(ByVal key As String) As Object
Get
End Get
Set(ByVal value As Object)
End Set
End Property

/claes

"Holger Kreissl" <di*******@gmail.comwrote in message
news:40**********************************@microsof t.com...
hello,
in C# you can define a property like this: public object this [string
key]
So you can acess a IDictonary member by the instance that holds the hash
or what ever.. I try to get it in vb but I cant find the way. Public
Property me(ByVal key As String) As Object doesnt work like this in C# for
the property. So how is the correct syntax for that issue?

Dont work:

Public Property me(ByVal key As String) As Object
Get
If (_data.ContainsKey(key)) Then
Return _data(key)
Else
Return Nothing
End If
End Get
Set(ByVal value As Object)
SetValue(key, value)
End Set
End Property

Thanks a lot!

--
Holger Kreissl
.NET Software Developer
http://kreissl.blogspot.com/

Jun 27 '08 #3
thanks!

Default Public Property Item(ByVal key As String) As Object
Get
End Get
Set(ByVal value As Object)
End Set
End Property

/claes
>in C# you can define a property like this: public object this [string
key]
So you can acess a IDictonary member by the instance that holds the hash
or what ever.. I try to get it in vb but I cant find the way. Public
Property me(ByVal key As String) As Object doesnt work like this in C#
for the property. So how is the correct syntax for that issue?

Dont work:

Public Property me(ByVal key As String) As Object
Get
If (_data.ContainsKey(key)) Then
Return _data(key)
Else
Return Nothing
End If
End Get
Set(ByVal value As Object)
SetValue(key, value)
End Set
End Property

Thanks a lot!

--
Holger Kreissl
.NET Software Developer
http://kreissl.blogspot.com/

Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4827
by: Lance | last post by:
I want to be able to reset a complex property in a PropertyGrid. I know that for properties that are ValueTypes you can include System.ComponentModel.DefaultValue in the declaration of the property....
3
6706
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
0
1416
by: Jordan Bowness | last post by:
I make a similar post in another newsgroup, but this example is simplified somewhat. I have a component (cmpMyComponent) with 2 properties. The 1st property is a string value (Description) and...
6
1850
by: Altman | last post by:
I would like to use an indexed property to access my private array of user controls. If I don't use an indexed property, the property will show up in my Properties Window during development. Is...
5
1933
by: RSH | last post by:
I havent been able to set a property from another class with out getting some sort of error. Can someone please tell me what I'm doing wrong here? Public Class Form1
2
2184
by: garyusenet | last post by:
I could do with something similiar, can you tell me if you think this would work for me, and if there's any advantage in working with controls this way than how I currently am. At the moment...
8
3398
by: Jordi Rico | last post by:
Hi, I've made the next inherited class in Visual Studio 2005: Public Class LabelEx Inherits System.Windows.Forms.Label Sub New() MyBase.New() Me.ForeColor = Color.Black Me.AutoSize = False...
2
2008
by: Lespaul36 | last post by:
I have a control that I have made that uses a custom class for storage of some of the information. I want it to display in the VS.Net 2003 property grid in the IDE like the Font property does, so...
0
1498
by: Hans Koller | last post by:
Hello group, I design a class to bind it to a property grid for easy modification of some settings. My problem is now that I want to raise an event when a settings has been changed. Thats not a...
1
1337
by: cday119 | last post by:
I have a Class with about 10 properties. All properties return right except for one. It is real annoying and I can't see why its not working. Maybe someone else can see something. It is the...
0
7054
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7057
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5357
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4798
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4495
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3000
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1310
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
570
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
199
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.