VB.Net WriteOnly Property to C# -


i wrote class part of custom control in vb.net. lets me toggle state of 3 linked labels, , set text of each 1 using text property. user allowed it. can convert enabled property , constructor without issue, unsure best method convert text property. function take 2 arguments, , indexer act on labelextender3, not on text in vb.net. correct way convert this?

public class labelextender3     private lbltemp(2) label      public writeonly property enabled boolean         set(value boolean)             if value                 lbltemp(0).forecolor = color.mediumblue                 lbltemp(1).forecolor = color.mediumblue                 lbltemp(2).forecolor = color.mediumblue             else                 lbltemp(0).forecolor = color.steelblue                 lbltemp(1).forecolor = color.steelblue                 lbltemp(2).forecolor = color.steelblue             end if         end set     end property      public writeonly property text(byval index integer) string         set(value string)             lbltemp(index).text = value         end set     end property      friend sub new(byref value1 label, byref value2 label, byref value3 label)         lbltemp(0) = value1         lbltemp(1) = value2         lbltemp(2) = value3     end sub end class 

you've come across feature vb.net has c# not: indexable properties.

more specifically, c# lacks ability declare them, able consume them (which added in c# 4.0) , might limited com interop use.

your best bet make method in case:

public void settext(int index, string value) {     lbltemp[index].text = value; } 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -