Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Everyone

I am working on a project in c# where I am stuck at an error
"Cannot implicitly convert type 'int' to 'string'"

Following is my code:
C#
int att = 0;
att = command.Parameters["@recNo"].Value;
rtn = att;

I even tried the below code but didn't help
C#
att = Convert.ToInt32(command.Parameters["@recNo"].Value);

Please Help

Thank You
Posted

1 solution

The error says you are trying to convert an int to string, not a string to int.

This tells me that rtn must be a string and you're trying to put att into it. The error should have shown you which line caused it. However, just do

C#
rtn = att.ToString();
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-Apr-15 16:36pm    
5ed.
—SA
JPais 8-Apr-15 14:46pm    
Thank You RyanDev
ZurdoDev 8-Apr-15 15:17pm    
You're welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900