Solved

Casting type of enumerators

Posted on 2004-09-01
2
236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

734 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