Solved

Casting type of enumerators

Posted on 2004-09-01
2
233 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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

773 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