|
-
Jan 12th, 2010, 08:54 AM
#1
Thread Starter
Hyperactive Member
optional parameters cannot have structure types?
ok i would just like to know why. optional parameters cannot have structure types?
-
Jan 12th, 2010, 09:09 AM
#2
Re: optional parameters cannot have structure types?
Optional parameters actually can have structure types, but only if that structure has a corresponding native data type, e.g. Int32 and Integer. The reason is that the default value for optional parameters must be either a constant or Nothing, but Nothing is only really nothing for reference types. For value types, Nothing is an instance with default values, which doesn't qualify as constant.
-
Jan 12th, 2010, 09:12 AM
#3
Re: optional parameters cannot have structure types?
http://www.vbforums.com/showthread.php?t=420153
 Originally Posted by jmcilhinney
When you declare an optional parameter you have to specify a constant as the default value. You cannot do that with a structure unless it is one of the in-built types. Colours are properties of the Color type, i.e. NOT constants. You can declare an optional parameter that is a class type but for the same reason the only default value you can give it is Nothing. The one exception to this is String because it is also an in-built type, even though it's a class.
-
Jan 12th, 2010, 09:17 AM
#4
Re: optional parameters cannot have structure types?
Well, at least I'm consistent! Basically the same answer, three and a half years apart. pacerier, hopefully this shows you why you should ALWAYS search before asking a question. There's a very high probability that you're not the first to ask it.
-
Jan 12th, 2010, 10:44 AM
#5
Thread Starter
Hyperactive Member
Re: optional parameters cannot have structure types?
ok sry 'bout dat, i will try to do more searching in the future before posting
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|