?
Solved

I don't quite understand why this code works... simple, but I just don't get it.

Posted on 2006-05-04
5
Medium Priority
?
243 Views
Last Modified: 2010-04-16
I don't understand why you can cast a CurrencyManager as a DataView.

int rowCount = (currManager as DataView).Count;

I don't see how that works, but it does. I know this is really simple, but looking at the class heirarchy for these objects, it just doesn't make sense to me.
0
Comment
Question by:PoeticAudio
  • 3
5 Comments
 
LVL 6

Author Comment

by:PoeticAudio
ID: 16610516
WAIT, MADE A MISTAKE...

It's the CurrencyManager.List that casts, but I still don't get it.

int rowCount = (currManager.List as DataView).Count;
0
 
LVL 9

Expert Comment

by:pallosp
ID: 16610598
I neither understand why it works for you.

I get a compile-time error in Visual Studio 2005:
Cannot convert type 'System.Windows.Forms.CurrencyManager' to 'System.Data.DataView' via a built-in conversion
0
 
LVL 6

Author Comment

by:PoeticAudio
ID: 16610648
read my second post
0
 
LVL 12

Accepted Solution

by:
gbzhhu earned 500 total points
ID: 16610671

From MSDN

<quote>
The object returned by the List property can be cast to any type that implements the IList interface. This will be commonly used when you know the type of the underlying list. For example, if you are data-bound to a DataSet, the underlying list is a DataView (which implements IList). Other classes that implement the interface (this is not a complete list) include Array, ArrayList, and CollectionBase.
</quote>

DataView implements IList as stated above, therefore the Count property is accessible

The wonders of Interfaces ;-)

0
 
LVL 6

Author Comment

by:PoeticAudio
ID: 16611686
ahh. Okay. Thanks man!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month16 days, 23 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question