for each loop
-
I know this sounds like a stupid question but i can't seem to get a for each loop to compile correctly. I tried...
for each (IpAddress ^addr in ipAddresses) { }
and...
IpAddress^ addr = nullptr for each (addr in ipAddresses) { }
but none of them compile. I know i could do a for loop but i would rather just do a for each. I searched but i cant seem to find anyone else having this problem. Thanks alot for any help here are some of the errors:
Error 1 error C2143: syntax error : missing 'in' before '^'
Error 2 error C2065: 'addr' : undeclared identifier
Error 3 error C3192: syntax error : '^' is not a prefix operator (did you mean '*'?)Don't be overcome by evil, but overcome evil with good
-
I know this sounds like a stupid question but i can't seem to get a for each loop to compile correctly. I tried...
for each (IpAddress ^addr in ipAddresses) { }
and...
IpAddress^ addr = nullptr for each (addr in ipAddresses) { }
but none of them compile. I know i could do a for loop but i would rather just do a for each. I searched but i cant seem to find anyone else having this problem. Thanks alot for any help here are some of the errors:
Error 1 error C2143: syntax error : missing 'in' before '^'
Error 2 error C2065: 'addr' : undeclared identifier
Error 3 error C3192: syntax error : '^' is not a prefix operator (did you mean '*'?)Don't be overcome by evil, but overcome evil with good
teejayem wrote:
here are some of the errors:
And what are the other errors? Sometimes some errors are caused because of the errors that occur before them. I guess these are errors for the first case. Your code should look like this:
foreach (IpAddress^ addr in ipAddresses) { }
#region signature my articles #endregion
-
teejayem wrote:
here are some of the errors:
And what are the other errors? Sometimes some errors are caused because of the errors that occur before them. I guess these are errors for the first case. Your code should look like this:
foreach (IpAddress^ addr in ipAddresses) { }
#region signature my articles #endregion
hey Giorgi thanks for your reply. these are some of the errors i get. Error 1 error C2143: syntax error : missing 'in' before '^' Error 2 error C2065: 'addr' : undeclared identifier Error 3 error C3192: syntax error : '^' is not a prefix operator (did you mean '*'?)
array^ ipAddresses = Dns::GetHostAddresses(Dns::GetHostName()); for each (IpAddress ^addr in ipAddresses) { }
i don't think it is any other part of the code that is failing because as soon as i comment the for each loop it compiles fine. Thanks, -- modified at 9:43 Thursday 11th October, 2007
Don't be overcome by evil, but overcome evil with good
-
hey Giorgi thanks for your reply. these are some of the errors i get. Error 1 error C2143: syntax error : missing 'in' before '^' Error 2 error C2065: 'addr' : undeclared identifier Error 3 error C3192: syntax error : '^' is not a prefix operator (did you mean '*'?)
array^ ipAddresses = Dns::GetHostAddresses(Dns::GetHostName()); for each (IpAddress ^addr in ipAddresses) { }
i don't think it is any other part of the code that is failing because as soon as i comment the for each loop it compiles fine. Thanks, -- modified at 9:43 Thursday 11th October, 2007
Don't be overcome by evil, but overcome evil with good
arraySystem::Net::IPAddress^^ ipAddresses =
System::Net::Dns::GetHostAddresses(System::Net::Dns::GetHostName());
for each(System::Net::IPAddress^ addr in ipAddresses)
System::Console::WriteLine( addr->ToString());