what is wrong with the following asp.net code?

Posted by Udaysimha under ASP.NET on 3/1/2012 | Points: 10 | Views : 4933 | Status : [Member] | Replies : 2
Hi All,

please let me know the wrong with following code in asp.net
<%
Application.Lock()
Application("counter") = CType(Application("counter") + 1, Int32)
Application.UnLock()
%>
<%
Application.Lock();
Application("counter") = Int32(Application("counter") + 1);
Application.UnLock();
%>

Thanks

uday


Responses

Posted by: Blessyjees on: 3/1/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,

your first block code is ok. but in the second block the second line will cause an error. you can use this as Convert.ToInt32(Application("counter") + 1)

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

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

Posted by: Hmanjarawala on: 3/1/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi write above same code like:


<%
Application.Lock();
Application("counter") = CType(Application("counter"), Int32) + 1;
Application.UnLock();
%>
<%
Application.Lock();
Application("counter") = Int32.Parse(Application("counter")) + 1;
Application.UnLock();
%>


Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

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

Login to post response