|
-
Nov 9th, 2009, 03:11 PM
#1
Using Extensions thought
I was just reading a developer question who asked something like
Why is this an error "ListBox1.ItemsCount"
The obvious response is a typo, missing period, forgot the period between Items and Count. But then what if it was not a mistake? Suppose they have an extension method?
Code:
<Runtime.CompilerServices.Extension()> _
Public Function ListCount(ByVal sender As ListBox) As Int32
Return sender.Items.Count
End Function
Reminds me back in the day when developers didn't include the proper import statements.
Any ways something to think about when recieving code from an outside source. Of course when sending code do not forget to send the extensions, it can be easy to forget if say they are linked to the code and not physically in the project folder or sub-folders.
-
Nov 9th, 2009, 04:06 PM
#2
Re: Using Extensions thought
I'm not sure why you put this in CC, as it is waaaay to serious for this forum. I read the same thread. However, your example is an extension ListCount, while you mention the user typing ItemsCount. I believe that you are correct with ListCount rather than ItemsCount from the original thread. While the OP could have been missing a period if they had typed ItemsCount, the same is not true with ListCount. I believe that ListCount was the correct property for VB6 and earlier, which is why somebody suggested that it looked like VB6 code.
Having said that, the point you were making is entirely valid, and probably should have been made somewhere more substantial than here.
My usual boring signature: Nothing
 
-
Nov 9th, 2009, 05:25 PM
#3
Re: Using Extensions thought
 Originally Posted by Shaggy Hiker
I'm not sure why you put this in CC, as it is waaaay to serious for this forum. I read the same thread. However, your example is an extension ListCount, while you mention the user typing ItemsCount. I believe that you are correct with ListCount rather than ItemsCount from the original thread. While the OP could have been missing a period if they had typed ItemsCount, the same is not true with ListCount. I believe that ListCount was the correct property for VB6 and earlier, which is why somebody suggested that it looked like VB6 code.
Having said that, the point you were making is entirely valid, and probably should have been made somewhere more substantial than here.
Yep, sounds like I used the wrong forum, my apologies
-
Nov 9th, 2009, 06:10 PM
#4
Re: Using Extensions thought
Don't apologize. In chit chat, that's a waste of time. Just DUCK!!
My usual boring signature: Nothing
 
-
Nov 9th, 2009, 06:22 PM
#5
Re: Using Extensions thought
Thread moved.
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
|