1

Is it possible to have multiple statements on a single line in the Visual Studio Immediate Window for C#?

The following post suggests it's possible for VB: https://stackoverflow.com/a/27554199/216440

However, when I try it in C# I get an End of expression expected error.

What I've tried is:

var p0 = command.Parameters[0];object v = p0.Value;

where command is a SqlCommand object.

If I split the expressions onto separate lines they each work. However, when they're on the same line, as above, I get that End of expression expected error.

This is in Visual Studio 2013 Update 5.

Simon Elms
  • 17,832
  • 21
  • 87
  • 103
  • 1
    You don't have a full-blown C# compiler at your finger-tips in that window. It likes an expression, as it says, that's about the extent of it. Some day they'll use Roslyn to make it smarter, that won't happen today and never in VS2013. – Hans Passant Sep 11 '17 at 22:21
  • @HansPassant: I'm curious, then, about the claim that is works for VB (see the link in my question). Is that answer wrong or is the behaviour fundamentally different for VB and C#? – Simon Elms Sep 12 '17 at 01:50
  • There is no common codebase here. VB has the edge because they've been doing it for, oh, about 30 years. – Hans Passant Sep 12 '17 at 06:32

1 Answers1

2

No, as far as I know, the Visual Studio Immediate Window does not support multi-line statements for C#.

Maciej Jureczko
  • 1,560
  • 6
  • 19
  • 23