Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VS2008 C#
dear all
when i write code below i get following error
can any one help me out
thanks in advance
nitin
 
error
"Type and identifier are both required in a foreach statement"
 

string path = null;
string Path2 = null;
string StrBackupPath = null;
int i1 = 0;
i1 = DataGrid_DisplayView.CurrentRow.Index;
 
if (StrBackupPath == null) {
	//path = Application.StartupPath & "\Images\" & DataGrid_DisplayView.Item(13, i1).Value
	path = "D:\\FilmPlus_MSAccess\\bin\\Debug\\Images\\" +
DataGrid_DisplayView.Item(13, i1).Value;
 

 

DicomDataSetCollection ddirs = new DicomDataSetCollection();
DicomDataSet ddir = new DicomDataSet();
 

DicomDataSet Patient = new DicomDataSet();
DicomDataSet Study = new DicomDataSet();
DicomDataSet series = new DicomDataSet();
DicomDataSet instance = new DicomDataSet();
DicomDataSetCollection pixelData = new DicomDataSetCollection();
int i = 0;
DicomImage im = new DicomImage();
 

 
//if root patient or study; cant open icons study wise
foreach ( Patient in ddir.Children) {
	foreach ( Study in Patient.Children) {
		foreach ( series in Study.Children) {
			foreach ( instance in series.Children) {
				pixelData = instance.Value(0x88, 0x200);
				//Attributes(&H88, &H200).Value
				ViewerStudy.Images.Add(pixelData(0));
			}
		}
	}
 
}
Posted 19-Jul-12 22:27pm
Edited 19-Jul-12 23:51pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The syntax of foreach is pretty simple:
foreach (Type variablename in Collection)
You have forgotten to add the variable name in each of the foreach statements, so it doesn't know where to put each instance in the collection:
foreach ( Patient patient in ddir.Children) {
    foreach ( Study study in patient.Children) {
        foreach ( series ser in study.Children) {
            foreach ( instance inst in ser.Children) {
                pixelData = inst.Value(0x88, 0x200);
  Permalink  
Comments
Member 8893861 at 20-Jul-12 5:25am
   
thanks for ur reply
but i am gettting new error
Error 1 foreach statement cannot operate on variables of type 'DicomObjects.DicomDataSets' because 'DicomObjects.DicomDataSets' does not contain a public definition for 'GetEnumerator' D:\nitin\imageaccess3\imageaccess3\Form1.cs 97 13 imageaccess3
 
regards
nitin
OriginalGriff at 20-Jul-12 5:40am
   
Then you need to look at which one of the statements it is, and identify which property is the collection...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 320
1 Peter Leow 155
2 ProgramFOX 145
3 DamithSL 140
4 Zoltán Zörgő 130
0 OriginalGriff 160
1 ProgramFOX 105
2 Sergey Alexandrovich Kryukov 60
3 Mehdi Gholam 50
4 DamithSL 50


Advertise | Privacy | Mobile
Web03 | 2.8.150224.1 | Last Updated 20 Jul 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100