Click to See Complete Forum and Search --> : VS.NET bug
KingTermite
February 26th, 2003, 08:46 PM
Hehe...this was interesting. A friend of mine sent me a small program that was giving him a unhandled exception upon running that he couldn't figure out. It compiled just fine, though, with no errors.
The problem was this line of code:
Console.WriteLine("byte equiv = {0)", directionByte);
Can you believe the compiler didn't catch this? :confused: :eek:
MartinL
March 3rd, 2003, 11:32 AM
Hm... And why do you think that the compiler should cath it???
No, it is normal behaviour! The format string could vary from one run of the program to another run... You can set the format string during the program execution. Compiler will just translate the code into the IL language and call WriteLine and pass that format string as parameter there... It is absolute o.k...
Martin
KingTermite
March 5th, 2003, 04:13 PM
As you said, it should just pass that to WriteLine, then WriteLine should have written: "{0)", but it seems to me that since {0} is the proper syntax for a variable replacement, it should have either returned a compile warning.
Just giving no compile warning and a string format exception seems like odd behavior to me.
pareshgh
March 7th, 2003, 05:39 PM
")" is not a escape char anyway.. so its treated as normal char.
Parehs
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.