Solved

Casting type of enumerators

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net - TypeInitializer Error 25 32
VB.Net Report Printing Issue 3 54
Convert Ctime to date time in textfile? 7 31
Get month and date in a format 4 31
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

840 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