Link to home
Start Free TrialLog in
Avatar of Valimai
Valimai

asked on

enable "option explicit" c#

Hi there,

I have a new computer and started coding a new project, C#.

I noticed i did not apply ToString() to a int variable when combining it with string.

E.g.
int maxLength = 50;
throw new Exception.EntityException_FieldLength("Last Name is limited to " + maxLength + " characters");

This compiles! How do i fix it so the compiler tells me to fix the code? For the life of me i cannot see the option in the editor.

I would expect to have to write
throw new Exception.EntityException_FieldLength("Last Name is limited to " + maxLength-->.ToString()<-- + " characters");

thanks!
ASKER CERTIFIED SOLUTION
Avatar of Dmitry G
Dmitry G
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Valimai
Valimai

ASKER

THanks for the articles and it does appear that the code works as designed.

I just can't believe that I could always do this with c#:
int myNumber = 5;
Response.Write("The number is " + myNumber);

No need to respond to this one. I will keep the question open for another day to see if anyone else has a view. Otherwise i will accept your answer.