File tree Expand file tree Collapse file tree 2 files changed +36
-15
lines changed
core/tutorials/vb-library-with-visual-studio
csharp/getting_started/with_visual_studio_2017 Expand file tree Collapse file tree 2 files changed +36
-15
lines changed Original file line number Diff line number Diff line change 11Imports UtilityLibraries
22
33Module Program
4- Sub Main()
5- Dim rows As Integer = Console.WindowHeight
4+ Dim row As Integer = 0
65
7- Console.Clear ()
6+ Sub Main ()
87 Do
9- If Console.CursorTop >= rows OrElse Console.CursorTop = 0 Then
10- Console.Clear()
11- Console.WriteLine( "\nPress <Enter> only to exit; otherwise, enter a string and press <Enter>:\n" )
12- End If
8+ If row = 0 OrElse row >= 25 Then ResetConsole()
9+
1310 Dim input As String = Console.ReadLine()
1411 If String .IsNullOrEmpty(input) Then Return
1512
1613 Console.WriteLine( $"Input: {input} {" Begins with uppercase? ",30}: " +
1714 $"{If(input.StartsWithUpper(), " Yes ", " No ")} {vbCrLf}" )
15+ row += 3
1816 Loop While True
1917 End Sub
18+
19+ Private Sub ResetConsole()
20+ If row > 0 Then
21+ Console.WriteLine( "Press any key to continue..." )
22+ Console.ReadKey()
23+ End If
24+ Console.Clear()
25+ Console.WriteLine( "{0}Press <Enter> only to exit; otherwise, enter a string and press <Enter>:{0}" ,
26+ vbCrLf)
27+ row = 3
28+ End Sub
2029End Module
30+
Original file line number Diff line number Diff line change @@ -5,21 +5,32 @@ class Program
55{
66 static void Main ( string [ ] args )
77 {
8- int rows = Console . WindowHeight ;
9-
10- Console . Clear ( ) ;
8+ int row = 0 ;
9+
1110 do
1211 {
13- if ( Console . CursorTop >= rows || Console . CursorTop == 0 )
14- {
15- Console . Clear ( ) ;
16- Console . WriteLine ( "\n Press <Enter> only to exit; otherwise, enter a string and press <Enter>:\n " ) ;
17- }
12+ if ( row == 0 || row >= 25 )
13+ ResetConsole ( ) ;
14+
1815 string input = Console . ReadLine ( ) ;
1916 if ( String . IsNullOrEmpty ( input ) ) break ;
2017 Console . WriteLine ( $ "Input: { input } { "Begins with uppercase? " , 30 } : " +
2118 $ "{ ( input . StartsWithUpper ( ) ? "Yes" : "No" ) } \n ") ;
19+ row += 3 ;
2220 } while ( true ) ;
21+ return ;
22+
23+ // Declare a ResetConsole local method
24+ void ResetConsole ( )
25+ {
26+ if ( row > 0 ) {
27+ Console . WriteLine ( "Press any key to continue..." ) ;
28+ Console . ReadKey ( ) ;
29+ }
30+ Console . Clear ( ) ;
31+ Console . WriteLine ( "\n Press <Enter> only to exit; otherwise, enter a string and press <Enter>:\n " ) ;
32+ row = 3 ;
33+ }
2334 }
2435}
2536
You can’t perform that action at this time.
0 commit comments