Click here to Skip to main content
11,501,968 members (69,085 online)

.NET Framework

 
AnswerRe: c# Pin
ThePhantomUpvoter1-Mar-13 3:00
memberThePhantomUpvoter1-Mar-13 3:00 
AnswerRe: c# Pin
Eddy Vluggen1-Mar-13 3:00
mvpEddy Vluggen1-Mar-13 3:00 
AnswerRe: c# Pin
ProgramFOX3-Mar-13 6:17
member ProgramFOX3-Mar-13 6:17 
QuestionI want to store webservice method's XML output as string in C# Pin
Member 982628125-Feb-13 0:21
memberMember 982628125-Feb-13 0:21 
AnswerRe: I want to store webservice method's XML output as string in C# Pin
Eddy Vluggen25-Feb-13 8:20
mvpEddy Vluggen25-Feb-13 8:20 
AnswerRe: I want to store webservice method's XML output as string in C# Pin
jschell25-Feb-13 9:01
memberjschell25-Feb-13 9:01 
Question[VB.NET 2008] Compact Framework: how to start a single instance of an application Pin
steve_949661324-Feb-13 23:28
membersteve_949661324-Feb-13 23:28 
AnswerRe: [VB.NET 2008] Compact Framework: how to start a single instance of an application Pin
Eddy Vluggen25-Feb-13 8:10
mvpEddy Vluggen25-Feb-13 8:10 
GeneralRe: [VB.NET 2008] Compact Framework: how to start a single instance of an application Pin
steve_949661325-Feb-13 23:44
membersteve_949661325-Feb-13 23:44 
GeneralRe: [VB.NET 2008] Compact Framework: how to start a single instance of an application Pin
Eddy Vluggen26-Feb-13 0:33
mvpEddy Vluggen26-Feb-13 0:33 
QuestionEvent Handling between Threads Pin
AeroClassics19-Feb-13 11:37
memberAeroClassics19-Feb-13 11:37 
AnswerRe: Event Handling between Threads Pin
Gerry Schmitz19-Feb-13 19:25
memberGerry Schmitz19-Feb-13 19:25 
GeneralRe: Event Handling between Threads Pin
AeroClassics20-Feb-13 4:45
memberAeroClassics20-Feb-13 4:45 
QuestionWays of implenting IEnumerable in VB Pin
Mike-MadBadger19-Feb-13 11:10
memberMike-MadBadger19-Feb-13 11:10 
OK, I cannot get my head around the whether there is a difference between the 'classic' (perhaps long winded) way of doing it, multiple classes and the 'new' Yield route to (apparently) the same end.

I can understand the classic route (I think), see the code below.
Yield confuses the heck out of me, if I understand it correctly then it's absolutely genius, I get the idea of a state machine (I think) and logically it sort of makes sense but I am not at all confident.

Can it possibly be this simple? You just make that one method as simple or complex as necessary for your situation?
(Warning, silly example since arrays can already be enumerated, but it's easy to demo)
Public Class YieldExample
    Implements IEnumerable
 
    Private _Thing As Double()
 
    Public Iterator Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
        If IsNothing(Me._Thing) Then
            Throw New InvalidOperationException()
        End If
 
        For Index As Integer = 0 To Me._Thing.GetUpperBound(0)
            Yield Me._Thing(Index)
        Next
    End Function
 
End Class
What I understand to be the 'old way'.
Public Class ExampleEnumerable
    Implements IEnumerable(Of Double)
 
    Private _Thing As Double()
 
    Public Function GetEnumerator() As IEnumerator(Of Double) Implements IEnumerable(Of Double).GetEnumerator
        Return New ExampleEnumerator(Me._Thing)
    End Function
 
    Public Function GetEnumerator1() As IEnumerator Implements IEnumerable.GetEnumerator
        Return Me.GetEnumerator
    End Function
End Class
 

 
Public Class ExampleEnumerator
    Implements IEnumerator(Of Double)
 
    Private _Thing As Double()
    Private _Index As Integer
    Private _curItem As Double
 
    Public Sub New(ByVal Thing As Double())
        Me._Thing = Thing
        Me._Index = -1
        Me._curItem = Nothing
    End Sub
 
    Public ReadOnly Property Current As Double Implements IEnumerator(Of Double).Current
        Get
            If IsNothing(Me._curItem) Then
                Throw New InvalidOperationException()
            End If
            Return Me._curItem
        End Get
    End Property
 
    Public ReadOnly Property Current1 As Object Implements IEnumerator.Current
        Get
            Return Me.Current
        End Get
    End Property
 
    Public Function MoveNext() As Boolean Implements IEnumerator.MoveNext
        'If we are already at the end then return false
        If Me._Index = Me._Thing.GetUpperBound(0) Then
            Return False
        End If
        'Otherwise move to the next position in the array
        Me._Index += 1
        Me._curItem = Me._Thing(Me._Index)
        Return True
    End Function
 
    Public Sub Reset() Implements IEnumerator.Reset
        Me._Index = -1
        Me._curItem = Nothing
    End Sub
 
    #Region "IDisposable Support"
 
End Class
Thanks,
Mike
AnswerRe: Ways of implenting IEnumerable in VB Pin
MicroVirus13-Mar-13 11:56
memberMicroVirus13-Mar-13 11:56 
GeneralRe: Ways of implenting IEnumerable in VB Pin
Mike-MadBadger13-Mar-13 21:44
memberMike-MadBadger13-Mar-13 21:44 
Questionhow to manage exicution code Pin
nanhesab18-Feb-13 0:58
membernanhesab18-Feb-13 0:58 
AnswerRe: how to manage exicution code Pin
Eddy Vluggen18-Feb-13 1:01
mvpEddy Vluggen18-Feb-13 1:01 
AnswerRe: how to manage exicution code Pin
Super Lloyd18-Feb-13 1:33
memberSuper Lloyd18-Feb-13 1:33 
AnswerRe: how to manage exicution code Pin
Sandeep Mewara18-Feb-13 3:13
mvpSandeep Mewara18-Feb-13 3:13 
Questionharvesting social images for bi concept image search Pin
krish888817-Feb-13 16:32
memberkrish888817-Feb-13 16:32 
AnswerRe: harvesting social images for bi concept image search Pin
N a v a n e e t h17-Feb-13 17:13
memberN a v a n e e t h17-Feb-13 17:13 
AnswerRe: harvesting social images for bi concept image search Pin
Sandeep Mewara17-Feb-13 18:24
mvpSandeep Mewara17-Feb-13 18:24 
AnswerRe: harvesting social images for bi concept image search Pin
Abhinav S19-Feb-13 0:08
mvpAbhinav S19-Feb-13 0:08 
AnswerRe: harvesting social images for bi concept image search Pin
Dave Kreskowiak19-Feb-13 1:45
mvpDave Kreskowiak19-Feb-13 1:45 
QuestionWhere to get Regasm and Gacutil? Pin
cjb11015-Feb-13 0:54
membercjb11015-Feb-13 0:54 
AnswerRe: Where to get Regasm and Gacutil? Pin
Richard Deeming15-Feb-13 1:01
memberRichard Deeming15-Feb-13 1:01 
GeneralRe: Where to get Regasm and Gacutil? Pin
cjb11015-Feb-13 2:55
membercjb11015-Feb-13 2:55 
AnswerRe: Where to get Regasm and Gacutil? Pin
Dave Kreskowiak15-Feb-13 2:12
mvpDave Kreskowiak15-Feb-13 2:12 
GeneralRe: Where to get Regasm and Gacutil? Pin
cjb11015-Feb-13 2:48
membercjb11015-Feb-13 2:48 
QuestionWeb development using C++ Pin
AseelHadlaq14-Feb-13 23:04
memberAseelHadlaq14-Feb-13 23:04 
AnswerRe: Web development using C++ Pin
N a v a n e e t h14-Feb-13 23:47
memberN a v a n e e t h14-Feb-13 23:47 
AnswerRe: Web development using C++ Pin
Dave Kreskowiak15-Feb-13 2:04
mvpDave Kreskowiak15-Feb-13 2:04 
AnswerRe: Web development using C++ Pin
Marco Bertschi15-Feb-13 3:27
memberMarco Bertschi15-Feb-13 3:27 
GeneralRe: Web development using C++ Pin
krysiaaa15-Feb-13 5:44
memberkrysiaaa15-Feb-13 5:44 
AnswerRe: Web development using C++ Pin
jschell15-Feb-13 9:11
memberjschell15-Feb-13 9:11 
AnswerRe: Web development using C++ Pin
Rahul Rajat Singh17-Feb-13 18:43
mvpRahul Rajat Singh17-Feb-13 18:43 
QuestionUSB Barcode scanner in C# Pin
Member 830583814-Feb-13 22:15
memberMember 830583814-Feb-13 22:15 
AnswerRe: USB Barcode scanner in C# Pin
Dave Kreskowiak15-Feb-13 2:05
mvpDave Kreskowiak15-Feb-13 2:05 
GeneralRe: USB Barcode scanner in C# Pin
Member 830583815-Feb-13 3:00
memberMember 830583815-Feb-13 3:00 
GeneralRe: USB Barcode scanner in C# Pin
Dave Kreskowiak15-Feb-13 3:33
mvpDave Kreskowiak15-Feb-13 3:33 
GeneralMessage Removed Pin
Member 984580018-Feb-13 19:33
memberMember 984580018-Feb-13 19:33 
GeneralRe: USB Barcode scanner in C# Pin
Dave Kreskowiak19-Feb-13 1:44
mvpDave Kreskowiak19-Feb-13 1:44 
QuestionwinRT xaml/C# listview selected index Pin
Clodetta del Mar14-Feb-13 4:38
memberClodetta del Mar14-Feb-13 4:38 
AnswerRe: winRT xaml/C# listview selected index Pin
Marco Bertschi15-Feb-13 3:33
memberMarco Bertschi15-Feb-13 3:33 
GeneralRe: winRT xaml/C# listview selected index Pin
Clodetta del Mar15-Feb-13 3:36
memberClodetta del Mar15-Feb-13 3:36 
GeneralRe: winRT xaml/C# listview selected index Pin
Marco Bertschi15-Feb-13 4:35
memberMarco Bertschi15-Feb-13 4:35 
GeneralRe: winRT xaml/C# listview selected index Pin
Clodetta del Mar18-Feb-13 22:28
memberClodetta del Mar18-Feb-13 22:28 
GeneralRe: winRT xaml/C# listview selected index Pin
Marco Bertschi18-Feb-13 23:18
memberMarco Bertschi18-Feb-13 23:18 
GeneralRe: winRT xaml/C# listview selected index Pin
Clodetta del Mar19-Feb-13 0:40
memberClodetta del Mar19-Feb-13 0:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 2 Jun 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid