简体   繁体   中英

Why do we need the question mark in Immediate Window of VS?

So, reading this documentation: https://learn.microsoft.com/en-us/visualstudio/ide/reference/immediate-window?view=vs-2022

It looks like the question mark (?) is an alias for the command >Debug.Print , which basically, will evaluate the expression and show the result.

So, in debug mode, instead of running this:

>Debug.Print DoSomething()

I can run this:

? DoSomething()

This is even better because I'm getting the autocomplete suggestions.

Now, the issue is that I can run the same line without a command at all, and it does exactly the same:

DoSomething()

So far looks like there is no need for the command >Debug.Print or the alias ? .

At first, I suspected that using ? will only print the result without changing the values, but this is not the case (When I assign a value to a variable using ? it is assigned and the new value is printed)

So, am I missing something here? Are there any other differences between these 3 options?

According to the documentation, if you want to use Visual Studio command, you need to add greater than sign before the command. If you run 'Debug.Print' without adding greater than sign, you will get an error. My point is that the question mark ('?') is unnecessary if you in the Immediate Window, it is used to distinguish the typed expression from the result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM