Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2004

Tip: Looking for answers? Try searching our database.

Default Property

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Levon Levonian - 07 May 2004 11:55 GMT
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
avnrao - 07 May 2004 12:21 GMT
You can create default properties using
System.ComponentModel.DefaultPropertyAttribute.

Av.
> Hello All,
>
[quoted text clipped - 15 lines]
> thank you,
> Levon
William Ryan eMVP - 07 May 2004 14:26 GMT
If you have indexed properties (or indexers in C#) which basically means
more than 1 value in the property, then you can use Default properties.
Avnroe shows you how to do it with an attribute
http://www.knowdotnet.com/articles/properties2.html
> Hello All,
>
[quoted text clipped - 15 lines]
> thank you,
> Levon
Levon Levonian - 07 May 2004 14:23 GMT
Thank you guys,

so, the name of Item property is just a convention?

// levon

> If you have indexed properties (or indexers in C#) which basically means
> more than 1 value in the property, then you can use Default properties.
[quoted text clipped - 19 lines]
> > thank you,
> > Levon
William Ryan eMVP - 07 May 2004 21:20 GMT
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.
> Thank you guys,
>
[quoted text clipped - 26 lines]
> > > thank you,
> > > Levon

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.