Break Long code lines in Visual Studio 2008

Hit the enter key.

public static somemethod(param1, 
    param2, 
    param3, 
    more params etc...)

...is perfectly valid.


C# is not line based, so you can split the statements anywhere but inside an identifier:

public static void somemethod(
   int param1,
   int param2,
   int param3,
   more params etc...
)

You can even write something like:

for
(
int
i
=
0
;
i
<
10
;
i
++
) 
{
Console
.
WriteLine
(
i
)
;
}

To break strings you can place a _ at the break in VB.Net and in C# you put @ before the string.

Code in C#:

string s=@"sdsdsdsd
dfdfdfdfdf
fdfdfdfdf";

Code in VB

s="fdfdfdfdfdf _
dfdfdfdfdfdf "

Tags:

C#