473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

I bug in the for each loop statement?

Is this a bug in the for each loop or am I coding something wrong (or is this
how its suppose to function and I don't understand how an array property and
the for each interact [this is always a possibility :)]

The commented out code is the problem area as it generates the error:
->for each statement cannot operate on variables of type 'overloaded-function'

using namespace System;

ref class ArrayProp
{
public:
ArrayProp(int size)
{
numArray = gcnew array<int>(size);
}

property array<int>^ NumArray
{
array<int>^ get()
{
return numArray;
}

void set ( array<int>^ value )
{
numArray = value;
}
}
private:
array<int>^ numArray;
};

void main()
{
ArrayProp aprop(5);

for ( int i = 0 ; i < aprop.NumArray->Count ; ++i )
aprop.NumArray[i] = i;

for ( int i = 0 ; i < aprop.NumArray->Count ; ++i )
Console::WriteLine(aprop.NumArray[i]);

// for each (int i in aprop.NumArray)
// {
// Console::WriteLine(i);
// }
}

Nov 17 '05 #1
1 868
Hello Stephen,

there are more appropiate groups on privatenews.microsoft.com for the VS
8 Beta.
Is this a bug in the for each loop or am I coding something wrong (or is this
how its suppose to function and I don't understand how an array property and
the for each interact [this is always a possibility :)] [...] // for each (int i in aprop.NumArray)
// {
// Console::WriteLine(i);
// }
}

this looks (didn't actually test it) like the bug described here
http://blogs.msdn.com/arich/. So it's a compiler bug, nothing you're
doing wrong.

Workaround is to explicitly call the property accessor.

hth
--
Ben
http://bschwehn.de
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Orin Hargraves | last post by:
I'm formatting data in a text file using a "For Each aPara" statement along with a "Next aPara." How do I make the thing stop when it reaches the end of the file, rather than starting again at the...
80
by: | last post by:
Is there a performance difference between this: \\\ Dim i As Integer For i = 0 to myObject.Controls.Count - 1 myObject.Controls(i) = ... Next /// and this:
3
by: deko | last post by:
Problem: why doesn't this With block work? is it possible to have a For Each loop within a With block? With objWord .Documents.Add Template:=strTemplate, NewTemplate:=False, DocumentType:=0...
8
by: Belee | last post by:
I have the following code and it is not passing through the Next statement: Private Function IsItemAlreadyAdded() As Boolean Dim drMyRow As DataRow With Me For Each drMyRow In...
3
by: Ben R. | last post by:
In an article I was reading (http://www.ftponline.com/vsm/2005_06/magazine/columns/desktopdeveloper/), I read the following: "The ending condition of a VB.NET for loop is evaluated only once,...
6
by: Teddy.Gammell | last post by:
Hi, I would like to write a function which does this: for each element in the list call f1() of each element. if f1() return false, break the loop else continue I try to use the...
14
by: Drew | last post by:
I need to iterate through a submitted form, inserting data on each pass. In the past, I have always used form elements that were named with numbers at the end, like this, name1 relationship1...
13
by: cj | last post by:
When I running a loop: For Each File As System.io.FileInfo In FileInfo Is there a way to tell which file number (index) I'm currently on? Actually I'd like the ability to skip to a particular...
1
by: ll | last post by:
Hi all, I've inherited a site and am currently looking to redesign a page that displays a table of course curriculum, with each row representing a "Topic" of the curriculum. There is a courseID...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.