The debugger uses a context in which the current instruction pointer (a small yellow arrow to the left of the source window) attempts to evaluate the function.
So, if the line of code where you left off has "using System"; at the top of the file, you can enter Convert.ToInt32 (123) in the viewport. If you are in another file that does not have this, you will need to fully name it.
I tried this with the following test case:
// Main.cs using System; namespace TestCon { class Program { static void Main(string[] args) { Foo foo = new Foo(); Console.WriteLine(Convert.ToString(123)); Console.WriteLine(Convert.ToInt32("234")); } } } //Foo.cs (note that there are no using statements in this file) namespace TestCon { class Foo { public Foo() { } } }
If I go to any point in the main.cs file, I can copy the Convert expressions to the viewport without the System namespace qualifier, and they will evaluate. If I find (or run to a breakpoint) in my Foo () constructor, I get the error message "The name" Convert "does not exist in the current context" unless I add a namespace classifier to it.>
Note. Even when the expression can be evaluated, you often have to remove the refresh button (the two arrows in the circle to the right of the time zone window), because the debugger cannot determine if the call to the CLR is triggered causes side effects.
Hope this helps.
source share