• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

Casting type of enumerators

Hello experts,

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


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


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(CType(myEnum.Current.Row.item("BasicInfoID"), Int16))
     '***dr = CType(myEnum.Current, DataRowView).Row
     '***dr.Item("Status") = "Expired"
End While
  • 2
1 Solution
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"))

And remember

Enumerators only allow reading the data in the collection. Enumerators cannot be used to modify the underlying collection
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now