Hi,
It's very simple,
(string)p + 1 means:
1)- treat p as string
2)- to the result of the above operation add the numeric value 1
Now this will ALWAYS FAIL because:
if p is numeric 1) will give error, as you cannot cast a numeric value to
string.
if p is convertible to string, then the error will be in 2) as 1 is numeric
and you cannot sum a numeric and a string value
The only way to do this is using convertion. now there is two possible ways
of doing so:
1) Convert.ToString( p + 1)
2- (p+1).ToString()
I would STRONGLY recommend 1 as it's clearer.
Hope this help,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"valmir cinquini" <vc*******@ig.com.br> wrote in message
news:ca**************************@posting.google.c om...
hy = new System.Web.UI.WebControls.HyperLink();
Why this doesn't work?
if(something == true)
hy.NavigateUrl = "email.aspx?id=" + (string) p+1; ****
but this works correctly?
if(something == true)
hy.NavigateUrl = "email.aspx?id=" + Convert.ToString(p+1);
**** this way I got the following error:
Cannot convert type 'int' to 'string'
Why? (string) shouldn't cast p+1 result to a string?
TIA