Undocumented problem with for each
-
Code is self explanitory. Adding braces around the for each block fixes it, but this shouldn't be required. Unless of course you can point me to something that says this is expected behaviour. Jody Steele -----CODE START----- using namespace System; using namespace System::Collections; int main(array ^args) { //Define a test array ArrayList test; //Populate it with some data test.Add(3); test.Add(4); test.Add(13); test.Add(42); //Works as expected: WriteLine not called if (false) Console::WriteLine("Test"); //Works as expected: for not entered if (false) for(int i=0;i
-
Code is self explanitory. Adding braces around the for each block fixes it, but this shouldn't be required. Unless of course you can point me to something that says this is expected behaviour. Jody Steele -----CODE START----- using namespace System; using namespace System::Collections; int main(array ^args) { //Define a test array ArrayList test; //Populate it with some data test.Add(3); test.Add(4); test.Add(13); test.Add(42); //Works as expected: WriteLine not called if (false) Console::WriteLine("Test"); //Works as expected: for not entered if (false) for(int i=0;i
Just in case my message about what fixes it wasn't clear: Bad: ----CODE---- if (false) for each (int i in test) { Console::Write("for each "); Console::WriteLine(i); } ----CODE END---- Good: ----CODE---- if (false) { for each (int i in test) { Console::Write("for each "); Console::WriteLine(i); } } ----CODE END---- But yeah... Original question still stands: Is this a "feature" or a genuine bug?
-
Code is self explanitory. Adding braces around the for each block fixes it, but this shouldn't be required. Unless of course you can point me to something that says this is expected behaviour. Jody Steele -----CODE START----- using namespace System; using namespace System::Collections; int main(array ^args) { //Define a test array ArrayList test; //Populate it with some data test.Add(3); test.Add(4); test.Add(13); test.Add(42); //Works as expected: WriteLine not called if (false) Console::WriteLine("Test"); //Works as expected: for not entered if (false) for(int i=0;i
Definitely looks like a bug to me. Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
Currently working on C++/CLI in Action for Manning Publications.