Chris Csernica
It's the very next line, so it would be very odd if it had fallen out of scope at that point.
This is just the generic Dictionary class, it should be the default IEnumerator implementation for its ValueCollection. Now that I've taken a closer look at the official docs, I see it's indeed a value type.
(That means I can positively NOT recommend Pro Visual C++/CLI and the .NET 2.0 Platform by Stephen Fraser, to which I resorted for lack of examples in the official docs. Not only is it an annoying read with his conversational interjections and typographical errors, but now I know his examples can be wrong. His discussion of the ValueCollection and KeyCollection classes on pp. 274-277 clearly shows Dictionary<>::ValueCollection::Enumerator as a handle.)
Unfortunately, a correct declaration doesn't fix the problem. The compiler still doesn't see the variable as having been declared, and still doesn't appear to see the Value method of a Dictionary.
I'll post the actual code and compiler errors in a few minutes.
Hah. A few minutes, I says. Sorry if this is a bit messy; I didn't have much luck screwing around with it to make it look good.
Code Snippet
7 using namespace System;
8 using namespace System::Collections::Generic;
...
12 public ref struct dwell_info {
...
19 DateTime start_time;
20 DateTime end_time;
21 dwell_status_values status;
22 };
23
24 public ref class dwells {
25
26 static Dictionary<String^, Generic::Queue<dwell_info^>^> ^dwell_list;
...
89 static DateTime cur_dwell_start() {
90 Dictionary<String^, Generic::Queue<dwell_info>^>::ValueCollection::Enumerator stpr
91 = dwell_list->Values;
92 if (!sptr.MoveNext()) {
93 return DateTime::MinValue;
94 }
95 return sptr.Current->Peek().start_time;
};
Compile-time output:
1>------ Build started: Project: dutp_utilities, Configuration: Debug Win32 ------
1>Compiling...
1>Stdafx.cpp
1>Compiling...
1>dutp_utilities.cpp
1>c:\documents and settings\csernica\my documents\visual studio 2005\projects\dutp\dutp_utilities\dutp_dwells.h(92) : error C2065: 'sptr' : undeclared identifier
1>c:\documents and settings\csernica\my documents\visual studio 2005\projects\dutp\dutp_utilities\dutp_dwells.h(92) : error C2228: left of '.MoveNext' must have class/struct/union
1> type is ''unknown-type''
1>c:\documents and settings\csernica\my documents\visual studio 2005\projects\dutp\dutp_utilities\dutp_dwells.h(95) : error C2228: left of '.Current' must have class/struct/union
1> type is ''unknown-type''
1>c:\documents and settings\csernica\my documents\visual studio 2005\projects\dutp\dutp_utilities\dutp_dwells.h(95) : error C2227: left of '->Peek' must point to class/struct/union/generic type
1>c:\documents and settings\csernica\my documents\visual studio 2005\projects\dutp\dutp_utilities\dutp_dwells.h(95) : error C2228: left of '.start_time' must have class/struct/union
1>asmcs_report_reader.cpp
1>c:\documents and settings\csernica\my documents\visual studio 2005\projects\dutp\dutp_utilities\dutp_dwells.h(92) : error C2065: 'sptr' : undeclared identifier
1>c:\documents and settings\csernica\my documents\visual studio 2005\projects\dutp\dutp_utilities\dutp_dwells.h(92) : error C2228: left of '.MoveNext' must have class/struct/union
1> type is ''unknown-type''
1>c:\documents and settings\csernica\my documents\visual studio 2005\projects\dutp\dutp_utilities\dutp_dwells.h(95) : error C2228: left of '.Current' must have class/struct/union
1> type is ''unknown-type''
1>c:\documents and settings\csernica\my documents\visual studio 2005\projects\dutp\dutp_utilities\dutp_dwells.h(95) : error C2227: left of '->Peek' must point to class/struct/union/generic type
1>c:\documents and settings\csernica\my documents\visual studio 2005\projects\dutp\dutp_utilities\dutp_dwells.h(95) : error C2228: left of '.start_time' must have class/struct/union
1>Build log was saved at "file://c:\Documents and Settings\csernica\My Documents\Visual Studio 2005\Projects\dutp\dutp_utilities\Debug\BuildLog.htm"
1>dutp_utilities - 10 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========