Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a class I'm exposing to the user via the PropertyGrid, so my property names have to make sense. One of the properties needs to be "Optional." Normally, the code in my class would simply be as follows...

 

 

Private mbOptional As Boolean

 

<System.ComponentModel.Category("Behavior"), _

System.ComponentModel.DefaultValue(False)> _

Public Property Optional() As Boolean

Get

Return mbOptional

End Get

Set(ByVal vOptional As Boolean)

mbOptional = vOptional

End Set

End Property

 

 

However, the word "Optional" as a property name is not allowed since it's a reserved word. But it seems there should be a way to have a Property with any name you want, whether it's "Optional", "Integer", or whatever. Any ideas on how it's possible, or isn't it?

  • *Experts*
Posted

Just a suggestion - property names are generally nouns, not adjectives. You could use an adjective and noun - maybe something OptionalColor. In six months, you'll be typing [class]. and the intellisense is going to show you "Optional" and you'll think - what goes in *there*??

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...