michaelkrauklis
Programmer
I'm having a problem; I'm getting an Invalid Cast exception thrown when I try to add strings. Here's the code:
Now the second statement, where I have
works, but the first += does not. At this particular point even if I simplify the code to just a concatonation of a string it doesn't work unless I have the
statement (eg. the code
fails). This just doesn't make sense to me. The += isn't the problem either because the code
fails as well. It might help that type is an enumerated type, hence the casting to int, but if I just do a straight
it prints out the correct value in string format. Whaaa? MYenigmaSELF:-9
myenigmaself@myenigmaself.gaiden.com
"If debugging is the process of removing bugs, then programming must be the process of putting them in." --Dykstra
Code:
string user="SELECT Password FROM InternalUserPwd where UserName = '"+usr+"'";
if(checktype)
{
user+=" and UserType = " + type.ToString();
user+=" and RoleID = " + ((int)type).ToString();
Code:
<user+=" and RoleID = " + ((int)type).ToString();>
Code:
<((int)type).ToString();>
Code:
<user+="some string";>
Code:
<user=user+"some string";>
Code:
<Console.WriteLine(type.ToString());>
myenigmaself@myenigmaself.gaiden.com
"If debugging is the process of removing bugs, then programming must be the process of putting them in." --Dykstra