What is the StackOverFlow exception in vb.net?

I don’t even know what caused this in my application. What is it? I created a new instance of the class (the class was in a different file), but the first time I call the method, it throws a StackOverFlow exception.

The only thing that in my opinion logically throws a stackoverflow exception would be if someone ran Jon Skeet.

Now seriously, what is it? I went around it by creating another class in the same file as the first class, and used it to call methods for me.

+3
source share
9 answers

, , ( ) . , , .

- ( PL).

function int length(list l) {
    if (empty(l)) {
        return 0;
    } else {
        return 1 + length(l);  // should be 'return 1 + length(tail(l));
    }
}

. , .

( - ... ... .)

+6

stackoverflow - , , . , , , - .

void MyMethod()
{
    MyMethod();
}

, , .

P.S. SO ( .NET), .

+4

StackOverFlows - , , . - , . , A B B A. .

+2

, , , StackOverflowException , . , - , . , , , , " " apt.

+2

- , , , . , Main A, A B, c, d e, . . , B C, D... .., , "" - .

, ( B B, B...) - . , , , .

, , - , . , , , .

+2

, . . , - A B, ..

:)

+1

VB6 VB.NET, . , . , VB : . , , , .. ( 2 10 ...), , , .

TL; DR: DirectCast() ( ), VB .

0

, , lstEncounter. ++, , . , :

Property Encounter(ByVal N As Integer)
    Get
        If N < lstEncounters.Count Then
            Return Encounter(N)
        Else
            Return Nothing
        End If
    End Get
    Set(value)
        lstEncounters(N) = value
    End Set
End Property
0

Stackoverflow. , 1 , . 2500-3000 stackoverflow. DO... Loop, , VB Express:

:

Public Sub mainloop()

Dim cntr as integer

If cntr >= 5000  ( I just picked a number at random)

    me.close  ( I close the program)

...               (This is where I would manipulate the cntr for diff 
results)

cntr = cntr + 1  ( increment the cntr)

mainloop()        (re call my loop) 

End IF

End Sub

( , 2500-3000 Stackoverflow)

: ( )

Dim LoopCntr as integer

Do While LoopCntr <= 40000  (this my number.. Use your own number)

If LoopCntr > 40000 Then

        Exit Do
End If

mainloop()       (The mainloop() has not been changed just the method of calling it)
LoopCntr = LoopCntr + 1

Loop

me.close        (When LoopCntr reaches max it closes the program)

( Do..Loop 40000 "Stackoverflow" )

-1

Source: https://habr.com/ru/post/1546743/


All Articles