Solved

Casting type of enumerators

Posted on 2004-09-01
2
230 Views
Last Modified: 2010-04-23
Hello experts,

An easy question I should know.  What or how does this need to be casted with Option Strict on?

Console.WriteLine(myEnum.Current.Row.Item("BasicInfoID"))

I thought Enums where int16 varible types but I am having a hard time casting it.

Thanks,
-Tim

The commented lines ('***) are the solution I had to use because I can not cast.

Dim myEnum As IEnumerator = ds.Tables("utblBasicInfo").DefaultView.GetEnumerator()
'***Dim dv As DataRowView
'***Dim dr As DataRow
While myEnum.MoveNext
     Console.WriteLine(myEnum.Current.Row.Item("BasicInfoID"))
     'Console.WriteLine(CType(myEnum.Current.Row.item("BasicInfoID"), Int16))
     '***dr = CType(myEnum.Current, DataRowView).Row
     '***dr.Item("Status") = "Expired"
     '***Console.WriteLine(dr.Item("BasicInfoID"))
     '***Console.WriteLine(dr.Item("Status"))
End While
0
Comment
Question by:timmyzx7r
  • 2
2 Comments
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 50 total points
ID: 11951855
Option strict on, disallows late binding

and the .current property returns an object so you have to cast like this

Console.WriteLine(CType(myEnum.Current, datarowview).Row.item("BasicInfoID"))



0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11951962
And remember

Enumerators only allow reading the data in the collection. Enumerators cannot be used to modify the underlying collection
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now