Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi!

 

I've been a VB.net programmer for... allways :p but now I'm digging a little bit on C#.

I'm facing a trouble that I don't know if it's me or if it's C#...

 

I would like you to translate me this property to C#:

    
   Private at As New Hashtable
   Public Property value(ByVal key As Object) As Object
       Get
           Return at.Item(key)
       End Get
       Set(ByVal Value As Object)
           at.Item(key) = Value
       End Set
   End Property

 

Note: The main problem here its the property with arguments...

 

Thanks

Alex :p

Software bugs are impossible to detect by anybody except the end user.
Posted
Hi!

 

I've been a VB.net programmer for... allways :p but now I'm digging a little bit on C#.

I'm facing a trouble that I don't know if it's me or if it's C#...

 

I would like you to translate me this property to C#:

    
   Private at As New Hashtable
   Public Property value(ByVal key As Object) As Object
       Get
           Return at.Item(key)
       End Get
       Set(ByVal Value As Object)
           at.Item(key) = Value
       End Set
   End Property

 

Note: The main problem here its the property with arguments...

 

Thanks

Alex :p

 

C# uses brackets for indexed items. try at[key] or at.item[key].

Posted

I got this from the Instant C# VB to C# converter:

 

private Hashtable at = new Hashtable();

//ORIGINAL LINE: Public Property value(ByVal key As Object) As Object

//INSTANT C# WARNING: C# does not support parameterized properties - the following property has been divided into two methods:

public object Getvalue(object key)

{

return at[key];

}

public void Setvalue(object key, object Value)

{

at[key] = Value;

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...