Default Property

  • Thread starter Thread starter Levon Levonian
  • Start date Start date
L

Levon Levonian

Hello All,

there was much talk about the fact that .NET doesn't support default
properties for objects, meaning that if in VB6 i could have Textbox1 =
"hello", in .NET i can do it only by refering explicitly to the property
Textbox1.Text = "hello".

why then some objects like DataRow still have default properties?
dr.Item("ID")
and
dr("ID")
both work fine and serve the same purpose

and of course, my quesion is how to create a default property for my own
classes? is it by including the Item property when i design my classes? or
is there some other tricks? :)

thank you,
Levon
 
You can create default properties using
System.ComponentModel.DefaultPropertyAttribute.

Av.
 
Item is used by default but it could be any name you want. I'd recommend
using Item though in most cases to be consistent.
 
Back
Top