Compiler Error Message: CS0029: Cannot implicitly convert type 'int' to 'string' in C# .NET 4 -
i need convert string of input of table database integer value in c# .net 4 , tried code inspired link:
int i; string entry_level = convert.toint32("2,45"); = convert.toint32(entry_level);
but i've error:
compiler error message: cs0029: cannot implicitly convert type 'int' 'string'
edit
solved with:
decimal i; string entry_level = "2,45"; = convert.todecimal(entry_level); response.write(i.tostring()); response.end();
in output i've 2,45, many thanks!
string entry_level = convert.toint32("2,45");
should be
string entry_level = "2,45";
why not go though:
int = 2,45;
but since not integer, you'll need 1 of built-in decimal types:
/* use when precision matters lot, example when unit price or percentage value multiplied big numbers */ decimal = 2.45 /* use when precision isn't important part. it's still precise, can in trouble when dealing small or big numbers. doubles fine in cases.*/ double = 2.45
Comments
Post a Comment