AlexCode Posted March 9, 2005 Posted March 9, 2005 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 Quote Software bugs are impossible to detect by anybody except the end user.
kasdoffe Posted March 9, 2005 Posted March 9, 2005 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]. Quote
RobEmDee Posted March 9, 2005 Posted March 9, 2005 (edited) Alex: C# does not support parameterized properties. Check out Indexers . Edited March 9, 2005 by RobEmDee Quote
Diesel Posted March 9, 2005 Posted March 9, 2005 In the future, you can use .Net Reflector to convert code. Quote
Jaco Posted March 10, 2005 Posted March 10, 2005 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; } Quote
AlexCode Posted March 11, 2005 Author Posted March 11, 2005 hummmm... kind of stupid issue but... ok... Thanks! Alex:p Quote Software bugs are impossible to detect by anybody except the end user.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.