problem accesing object after if else

  • Thread starter Thread starter Jeroen Ceuppens
  • Start date Start date
J

Jeroen Ceuppens

Hi,

I have a problem accesing h, when i want to do h.Run() after the if else
structure, i get the following error: (see below for code)

C:\Documents and Settings\Eindwerk\Mijn documenten\BARCO\Eindwerk\Project
Files\thuis\13december\Aviewerversie02\FileLoad.cs(417): The type or
namespace name 'h' could not be found (are you missing a using directive or
an assembly reference?)

C:\Documents and Settings\Eindwerk\Mijn documenten\BARCO\Eindwerk\Project
Files\thuis\13december\Aviewerversie02\FileLoad.cs(418): The name 'h' does
not exist in the class or namespace 'Aviewerversie02.FileLoad'

How can i fix this?

Greetz
JC


LijstNode loper;

loper=(LijstNode)treeViewSequence.Nodes[0];


while(loper.Nodes.Count!=0)

{

if ( loper is GetImageNode )

{

GetImageNode h = (GetImageNode)loper;

}

else if ( loper is ViewNode )

{

ViewNode h = (ViewNode)loper;

}

else if ( loper is CastNode )

{

CastNode h = (CastNode)loper;

}

else if ( loper is FilterNode )

{

FilterNode h = (FilterNode)loper;

}

else if ( loper is TimerNode )

{

TimerNode h = (TimerNode)loper;

}

h.Run();

loper=(LijstNode)h;

loper=(LijstNode)loper.Nodes[0];

}
 
You have to declare the variable outside of the condition blocks then set
the variable inside the conditions.
 
Hi

That doesn't work either:
it put LijstNode h on top of the code, and this error shows up

C:\Documents and Settings\Eindwerk\Mijn documenten\BARCO\Eindwerk\Project
Files\thuis\13december\Aviewerversie02\FileLoad.cs(399): A local variable
named 'h' cannot be declared in this scope because it would give a different
meaning to 'h', which is already used in a 'parent or current' scope to
denote something else

I need the same variable because after the if else block, i Need to the same
operation h.run() wheter it is GetImageNode h, a ViewNode h,..........


Peter Rilling said:
You have to declare the variable outside of the condition blocks then set
the variable inside the conditions.

Jeroen Ceuppens said:
Hi,

I have a problem accesing h, when i want to do h.Run() after the if else
structure, i get the following error: (see below for code)

C:\Documents and Settings\Eindwerk\Mijn documenten\BARCO\Eindwerk\Project
Files\thuis\13december\Aviewerversie02\FileLoad.cs(417): The type or
namespace name 'h' could not be found (are you missing a using directive or
an assembly reference?)

C:\Documents and Settings\Eindwerk\Mijn documenten\BARCO\Eindwerk\Project
Files\thuis\13december\Aviewerversie02\FileLoad.cs(418): The name 'h' does
not exist in the class or namespace 'Aviewerversie02.FileLoad'

How can i fix this?

Greetz
JC


LijstNode loper;

loper=(LijstNode)treeViewSequence.Nodes[0];


while(loper.Nodes.Count!=0)

{

if ( loper is GetImageNode )

{

GetImageNode h = (GetImageNode)loper;

}

else if ( loper is ViewNode )

{

ViewNode h = (ViewNode)loper;

}

else if ( loper is CastNode )

{

CastNode h = (CastNode)loper;

}

else if ( loper is FilterNode )

{

FilterNode h = (FilterNode)loper;

}

else if ( loper is TimerNode )

{

TimerNode h = (TimerNode)loper;

}

h.Run();

loper=(LijstNode)h;

loper=(LijstNode)loper.Nodes[0];

}
 
I want to write a function for that, but then i hqve got another problem:
see in newsgroup dotnet.framework.compactframework : losing object type
information


Peter Rilling said:
You have to declare the variable outside of the condition blocks then set
the variable inside the conditions.

Jeroen Ceuppens said:
Hi,

I have a problem accesing h, when i want to do h.Run() after the if else
structure, i get the following error: (see below for code)

C:\Documents and Settings\Eindwerk\Mijn documenten\BARCO\Eindwerk\Project
Files\thuis\13december\Aviewerversie02\FileLoad.cs(417): The type or
namespace name 'h' could not be found (are you missing a using directive or
an assembly reference?)

C:\Documents and Settings\Eindwerk\Mijn documenten\BARCO\Eindwerk\Project
Files\thuis\13december\Aviewerversie02\FileLoad.cs(418): The name 'h' does
not exist in the class or namespace 'Aviewerversie02.FileLoad'

How can i fix this?

Greetz
JC


LijstNode loper;

loper=(LijstNode)treeViewSequence.Nodes[0];


while(loper.Nodes.Count!=0)

{

if ( loper is GetImageNode )

{

GetImageNode h = (GetImageNode)loper;

}

else if ( loper is ViewNode )

{

ViewNode h = (ViewNode)loper;

}

else if ( loper is CastNode )

{

CastNode h = (CastNode)loper;

}

else if ( loper is FilterNode )

{

FilterNode h = (FilterNode)loper;

}

else if ( loper is TimerNode )

{

TimerNode h = (TimerNode)loper;

}

h.Run();

loper=(LijstNode)h;

loper=(LijstNode)loper.Nodes[0];

}
 
Back
Top