(E-Mail Removed) wrote:
> C++
>
> void SomeClass::SomeRoutine (void)
> { QuestionClass abc(__FUNCTION__);
> }
>
> In C++ when "SomeRoutine" runs the QuestionClass gets the name of the
> current function. It seems like I should be able to get this using
> reflection with C# but I have not been able to figure out how. Is
> there a way to do this?
See System.Environment.StackTrace or the System.Diagnostics.StackTrace
class. There's an example at
http://msdn2.microsoft.com/en-us/4ce0ktkk(VS.80).aspx
that shows how to get the current routine name using the StackTrace class.
>
> When this routine ends the destructor for QuestionClass is run. Is
> there a way in C# to insure that the class is destroyed in a similar
> fashion. The best way I can see is to make the class implement
> IDisposable and use a using clause wrapping the entire contents of
> the routine. Is there a better way?
No - that's the best you can do in C#.
-cd