Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VS2008C#
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 21:27pm
Edited 19-Jul-12 22: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
Your Filters
Interested
Ignored
     
0 Guruprasad.K.Basavaraju 350
1 Sergey Alexandrovich Kryukov 226
2 Shai Vashdi 220
3 OriginalGriff 183
4 Tadit Dash 135
0 Sergey Alexandrovich Kryukov 9,255
1 OriginalGriff 5,433
2 Peter Leow 4,100
3 Maciej Los 3,540
4 Abhinav S 3,333


Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 20 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid