vb.net - Multiple references pointing to the same string? -


is following simplification possible in vb.net?

example: text variable pointing string:

class form1     sub new()         dim text (what_type?) = addressof textbox1.text  'simplification         if text = "foo" text = "bar"  'actually accessing textbox1.text     end sub end class 

i think not possible, can wrong.

vb.net doesn't have pointers. can use properties:

public property text string             return textbox1.text     end     set(value string)         textbox1.text = value     end set end property 

you can use properties layer not expose control relevant informations:

if text = "foo" text = "bar"   

on way change control(f.e. label) without breaking code.

another approach using lambda expression:

dim settext = sub(str string) textbox1.text = str settext("test") dim gettext = function() textbox1.text dim text string = gettext() 

Comments