'using' statement in block 
Author Message
 'using' statement in block

Is it possible to have a 'using' statement only inside a block or do I have
to declare it for the entire file?


Sun, 24 Oct 2004 15:03:12 GMT  
 'using' statement in block
biondello,

    The "using" statement has two uses.  It can be used to declare a
namespace or a typedef when placed at the top of the file and used with '#'
placed before it.

    In code, however, the using statement is used to handle disposable
objects (those that implement IDisposable) to call IDispose::Dispose when
the block is exited.  In this case, you can use it in as many blocks as you
want.

    Hope this helps.

--
               - Nicholas Paldino [.NET MVP]


Quote:
> Is it possible to have a 'using' statement only inside a block or do I
have
> to declare it for the entire file?



Sun, 24 Oct 2004 20:34:09 GMT  
 'using' statement in block
Thanks. I was just looking for a way to limit the #using statement (for
namespaces) to block scope as it is possible in MC++. Unfortunately C# does
not seem to have this feature.



Quote:
> biondello,

>     The "using" statement has two uses.  It can be used to declare a
> namespace or a typedef when placed at the top of the file and used with
'#'
> placed before it.

>     In code, however, the using statement is used to handle disposable
> objects (those that implement IDisposable) to call IDispose::Dispose when
> the block is exited.  In this case, you can use it in as many blocks as
you
> want.

>     Hope this helps.

> --
>                - Nicholas Paldino [.NET MVP]



> > Is it possible to have a 'using' statement only inside a block or do I
> have
> > to declare it for the entire file?



Mon, 25 Oct 2004 04:09:18 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. The DLL Cann't using exe server?Blocked in CoCreateInstance()

2. Menu's using switch statements

3. Can't compile using statement

4. 'if else' statement in controversy

5. About 'if' statement

6. 'select' statement in SCO

7. putting 'if' statement in Makefile

8. 'Overlapping' 'using' statements giving compiler problems

9. Was: Understanding 'while' and 'switch' statements

10. Block structure, goto's and stack frames

11. Allocating a memory block that doesn't overlap physical memory

12. Indexing into a malloc'ed block

 

 
Powered by phpBB® Forum Software