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
55{
66 public static void Main ( )
77 {
8- string [ ] values = { "one" , null , "two" } ;
8+ string [ ] values = [ "one" , null , "two" ] ;
99 for ( int ctr = 0 ; ctr <= values . GetUpperBound ( 0 ) ; ctr ++ )
1010 Console . Write ( "{0}{1}" , values [ ctr ] . Trim ( ) ,
1111 ctr == values . GetUpperBound ( 0 ) ? "" : ", " ) ;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ public class Array2Example
55{
66 public static void Main ( )
77 {
8- string [ ] values = { "one" , null , "two" } ;
8+ string [ ] values = [ "one" , null , "two" ] ;
99 for ( int ctr = 0 ; ctr <= values . GetUpperBound ( 0 ) ; ctr ++ )
1010 Console . Write ( "{0}{1}" ,
1111 values [ ctr ] != null ? values [ ctr ] . Trim ( ) : "" ,
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public static void Main()
1111 if ( ! string . IsNullOrEmpty ( pages . CurrentPage . Title ) )
1212 {
1313 string title = pages . CurrentPage . Title ;
14- Console . WriteLine ( "Current title: '{0 }'" , title ) ;
14+ Console . WriteLine ( $ "Current title: '{ title } '") ;
1515 }
1616 }
1717 }
@@ -44,7 +44,7 @@ public Page PreviousPage
4444 {
4545 if ( _ctr == 0 )
4646 {
47- if ( _page [ 0 ] == null )
47+ if ( _page [ 0 ] is null )
4848 return null ;
4949 else
5050 return _page [ 0 ] ;
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ public static void Main()
1010 if ( current != null )
1111 {
1212 string title = current . Title ;
13- Console . WriteLine ( "Current title: '{0 }'" , title ) ;
13+ Console . WriteLine ( $ "Current title: '{ title } '") ;
1414 }
1515 else
1616 {
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ public static void Main()
1919
2020 public class Person
2121 {
22- public static Person [ ] AddRange ( string [ ] firstNames )
22+ public static Person [ ] AddRange ( params string [ ] firstNames )
2323 {
2424 Person [ ] p = new Person [ firstNames . Length ] ;
2525 for ( int ctr = 0 ; ctr < firstNames . Length ; ctr ++ )
You can’t perform that action at this time.
0 commit comments