3

Is there a way to execute methods with out parameters in Immediate window? For example, while debugging I want to check if a string variable value can be successfully parsed into datetime. To do that I want execute datetime.Tryparse in immediate window. Is there a way to execute it?

Sparrow
  • 2,548
  • 1
  • 24
  • 28
shanmuga raja
  • 685
  • 6
  • 19
  • 1
    What happened when you tried executing the method? – Servy Oct 13 '16 at 17:42
  • @Servy Suppose if I want to check the string variable result, I have to execute datetime.tryparse(result,somevariable). To do this the variable "somevariable" has to be declared beforehand (which i dont want to do because I'm just debugging my code in immediate window). Otherwise I will get the error error CS0103: The name 'somevariable' does not exist in the current context. – shanmuga raja Oct 13 '16 at 17:53
  • @shanmugaraja Yes, the variable needs to be declared. You'll have to declare it. – Servy Oct 13 '16 at 18:02
  • @Servy Can that be understood that you cannot execute a method with out parameter in immediate window unless you have a variable for the out parameter already declared? – shanmuga raja Oct 13 '16 at 18:10
  • I do understand it. What don't you understand about the fact that if you need a variable declared, that you should declare it? – Servy Oct 13 '16 at 20:18

1 Answers1

1

Just execute it in the immediate window:

enter image description here

Rom
  • 1,183
  • 1
  • 8
  • 18
  • The two lines of code DateTime dateTime;bool result = DateTime.TryParse(input,out dateTime); – shanmuga raja Oct 13 '16 at 18:00
  • No, only the TryParse. look at the immediate window in the image – Rom Oct 13 '16 at 18:01
  • 1
    Based on the code you shown, the two lines of code DateTime dateTime;bool result = DateTime.TryParse(input,out dateTime); is not part of my code.I want to debug the string variable "input" from my immediate window by executing the DateTime.TryParse method. – shanmuga raja Oct 13 '16 at 18:02