What use is the Tag property in .net

后端 未结 4 1749
暗喜
暗喜 2020-12-09 04:13

I have noticed the Tag properties with controls. Is it okay to use this to reference my custom objects, or should I stay away from it as it would require boxing and unboxin

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-09 04:26

    I don't think this would be a boxing or unboxing problem to use it the way you want. As far as I know, that Tag property is for the programmer's purpose only, so you can use it quite the way you need it to be used.

    Please see Control.Tag property on MSDN for further reference on how to use this property.

    For instance, I used to use it to input instructions to the user in Windows Forms applications. When the control GotFocus event triggered, the instructions Label.Text property was assigned the value of my control Tag property which contained the instruction string.

提交回复
热议问题