This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - how do i convert string to int in Server Side Method c#

Pankaj Thakur - Monday, April 15, 2013 2:30 AM:

Hello Community,
    I want to convert a value from string to int.
but when I convert it it shows an error that "Cannot  implicitly convert type 'Aras.IOM.Item' to 'int'  " 

I also Try Convert.ToInt32(); & Convert.ToInt64();


If any one have any idea how to convert into int or how to fetch value into int then please  Help me  .
The value which i fetch into string is also integer type. 

Thanks & Regards
Pankaj Thakur 



zahar - Monday, April 15, 2013 3:53 AM:

Can you post the code? From the error i can see that you trying to convert to value but Item. Possible that you used getItemProperty("attr_name").ToInt() ????

if so you need to use

int intVal;

if (int.TryParse(.getProperty("attr_name"), out intVal) {

// do something if managed to convert

} else {

//do something if not

}



Rahul. - Monday, April 15, 2013 8:04 AM:

Hello Pankaj,

 

Use this - Convert.ToDecimal(this.getProperty("property_name"))

 

Hope this helps

Rahul Dixit



Pankaj Thakur - Wednesday, April 17, 2013 4:31 AM:

Hello Rahul Sir and Zahar Sir,

    Thank you . its Working.

 

 

Thanks & Regards
Pankaj Thakur