well the problem has been solved for me. Now I am not using this piece of code. But to share with you , I was getting an Exception whenever I tried to run the project. The exception was.
Input string was not in a correct format.
Actually I had to use that string variable in a query in which I have to select a column having int data type.
I simply changed my database schema and modified that column to hold String data. And My problem was solved. I know this is not the ultimate solution for the problem, but i have to adopt it in order to run my project in some way or the other. But I still want to know why I was not able to convert that string to int. As the exception suggests that there was some problem in specifying String, that's why I thought that my Syntax might be wrong as I have very little practice with c#.