Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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"


C#
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\\" +
C#
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
Updated 19-Jul-12 22:51pm
v2

1 solution

The syntax of foreach is pretty simple:
C#
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:
C#
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);
 
Share this answer
 
Comments
Member 8893861 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 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900