Exception in vb while checking null value

Posted by Sahoo under VB.NET on 3/22/2012 | Points: 10 | Views : 2114 | Status : [Member] | Replies : 1

I want 2 check null value .I use following code. But the if condition line showing exception.It is giving a warning message like Variable sessionstring is used before it has been assigned.A null exception may occur at run time

For Each sessitem In Session.Contents

If Not String.IsNullOrEmpty(sessionString) Then

sessionString = sessionString & """" & sessitem & "|" & Session(sessitem).ToString() & """;"

End If


any Idea.


Posted by: Veerac85 on: 3/22/2012 [Member] Starter | Points: 25

if you are just talking about warning, it is simply saying sessionString is not assigned a value. string is a reference type and has to be assigned a value before using.

something like string sessionString = String.Empty;

Sahoo, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response