File tree Expand file tree Collapse file tree 5 files changed +6
-6
lines changed
snippets/csharp/System/NullReferenceException/Overview Expand file tree Collapse file tree 5 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ public class Array1Example
5
5
{
6
6
public static void Main ( )
7
7
{
8
- string [ ] values = { "one" , null , "two" } ;
8
+ string [ ] values = [ "one" , null , "two" ] ;
9
9
for ( int ctr = 0 ; ctr <= values . GetUpperBound ( 0 ) ; ctr ++ )
10
10
Console . Write ( "{0}{1}" , values [ ctr ] . Trim ( ) ,
11
11
ctr == values . GetUpperBound ( 0 ) ? "" : ", " ) ;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ public class Array2Example
5
5
{
6
6
public static void Main ( )
7
7
{
8
- string [ ] values = { "one" , null , "two" } ;
8
+ string [ ] values = [ "one" , null , "two" ] ;
9
9
for ( int ctr = 0 ; ctr <= values . GetUpperBound ( 0 ) ; ctr ++ )
10
10
Console . Write ( "{0}{1}" ,
11
11
values [ ctr ] != null ? values [ ctr ] . Trim ( ) : "" ,
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public static void Main()
11
11
if ( ! string . IsNullOrEmpty ( pages . CurrentPage . Title ) )
12
12
{
13
13
string title = pages . CurrentPage . Title ;
14
- Console . WriteLine ( "Current title: '{0 }'" , title ) ;
14
+ Console . WriteLine ( $ "Current title: '{ title } '") ;
15
15
}
16
16
}
17
17
}
@@ -44,7 +44,7 @@ public Page PreviousPage
44
44
{
45
45
if ( _ctr == 0 )
46
46
{
47
- if ( _page [ 0 ] == null )
47
+ if ( _page [ 0 ] is null )
48
48
return null ;
49
49
else
50
50
return _page [ 0 ] ;
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ public static void Main()
10
10
if ( current != null )
11
11
{
12
12
string title = current . Title ;
13
- Console . WriteLine ( "Current title: '{0 }'" , title ) ;
13
+ Console . WriteLine ( $ "Current title: '{ title } '") ;
14
14
}
15
15
else
16
16
{
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ public static void Main()
19
19
20
20
public class Person
21
21
{
22
- public static Person [ ] AddRange ( string [ ] firstNames )
22
+ public static Person [ ] AddRange ( params string [ ] firstNames )
23
23
{
24
24
Person [ ] p = new Person [ firstNames . Length ] ;
25
25
for ( int ctr = 0 ; ctr < firstNames . Length ; ctr ++ )
You can’t perform that action at this time.
0 commit comments