"mvarTransporter = New Party" is the offending code. If you remove that then it won't call itself, although I am not sure what you are trying to do.
|
|
Hi
I have a class as below in VB.NET. The issue is class calling itself. So vb.NET throwing Stock Overflow exception. But the same class is working fine in VB6 version of code in VB6.
How to resolve this issue?
public class Party
Private mvarpartyCode as string
Private mvarpartyName as string
Private mvarpartyType as string
Private mvarTransporter as Party
Public Sub New()
mvarPartycode= ""
mvarPartyName=""
mvarPartyType=""
mvarTransporter = New Party
End Sub
Public Property For PartyCode variable
Public Property for PartyName variable
Public Property for PartyType variable
Public property for Transporter variable
End Class
"mvarTransporter = New Party" is the offending code. If you remove that then it won't call itself, although I am not sure what you are trying to do.
If I solve your issue or you are happy with my response, please provide me with reputation by clicking the reputation link at the top right of my posts - thanks
Hi
I want to intilize the mvarTransporter variable in the constructer of the class.
but you have declared mvarTransporter as you class, so basically it is initiallising itself over and over again. Why would you want to do that?
If I solve your issue or you are happy with my response, please provide me with reputation by clicking the reputation link at the top right of my posts - thanks
Hi
As per rule, the class variables need to be intialize at the construter of the class and not in the declaration.
In the declaration, I did not intialize the variable. Even I intialize the variable the declaration itself, It is throwing stock overflow exception.
the fact that you have set variable mvarTransporter = New Party means that you are just causing a loop. I can't make it any clearer than that to be honest.
If I solve your issue or you are happy with my response, please provide me with reputation by clicking the reputation link at the top right of my posts - thanks
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks