--- Stephen Simpson <[EMAIL PROTECTED]> wrote:
> switch (i)
> {
> case 1:
> StreamReader inFile
> =new StreamReader("type1.txt", Encoding.ASCII);
> FileMgrType1
> fileMgr = new FileMgrType1();
> break;
> case 2:
> StreamReader inFile
> =new StreamReader("type2.txt", Encoding.ASCII);
> FileMgrType2
> fileMgr = new FileMgrType2();
> break;
> }
I'm not sure I understand you but:
1) Move "StreamReader inFile" to outside of the switch block, merely assign it inside
the block:
2) Use the base class of the FileMgrTypes or better still define an interface then
assign that
inside the switch blocks.
i.e.
StreamReader inFile = null;
IFileManagerInterface itf = null;
//blah, blah
switch(i) {
case 1:
inFile = new StreamReader(...);
itf = new FileMgrType1();
//etc
Is that what you want?
Peter
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.