int i = 10; for (i = 1; i <= 10; i++) { if ((i % 2) = 0) continue ; Console .WriteLine(i); } * This source code was highlighted with Source Code Highlighter .
int i = 10; for (i = 1; i <= 10; i++) { if ((i % 2) = 0) continue ; Console .WriteLine(i); } * This source code was highlighted with Source Code Highlighter .
int i = 10; for (i = 1; i <= 10; i++) { if ((i % 2) = 0) continue ; Console .WriteLine(i); } * This source code was highlighted with Source Code Highlighter .
int i = 10; for (i = 1; i <= 10; i++) { if ((i % 2) = 0) continue ; Console .WriteLine(i); } * This source code was highlighted with Source Code Highlighter .
int i = 10; for (i = 1; i <= 10; i++) { if ((i % 2) = 0) continue ; Console .WriteLine(i); } * This source code was highlighted with Source Code Highlighter .
int i = 10; for (i = 1; i <= 10; i++) { if ((i % 2) = 0) continue ; Console .WriteLine(i); } * This source code was highlighted with Source Code Highlighter .
int i = 10; for (i = 1; i <= 10; i++) { if ((i % 2) = 0) continue ; Console .WriteLine(i); } * This source code was highlighted with Source Code Highlighter .
int i = 10; for (i = 1; i <= 10; i++) { if ((i % 2) = 0) continue ; Console .WriteLine(i); } * This source code was highlighted with Source Code Highlighter .
int i = 10; for (i = 1; i <= 10; i++) { if ((i % 2) = 0) continue ; Console .WriteLine(i); } * This source code was highlighted with Source Code Highlighter .
* This source code was highlighted with Source Code Highlighter .
- static void Main ( string [] args)
- {
- int myInt;
- Console .WriteLine ( "Enter an integer:" ); // Enter an integer
- Int32 .TryParse ( Console .ReadLine (), out myInt);
- Console .WriteLine ( "Integer less than 10? {0}" , myInt <10);
- Console .WriteLine ( "Integer between 0 and 5? {0}" , (myInt> = 0) && (myInt <= 5));
- Console .ReadKey ();
- }
* This source code was highlighted with Source Code Highlighter .
- static void Main ( string [] args)
- {
- string result = String .Empty;
- double var1 = 0, var2 = 0;
- begin1:
- Console .WriteLine ( "Enter first number:" );
- if (! Double.TryParse ( Console .ReadLine (), out var1)) // here I simplified the code by simply putting "!" before bool expression
- {
- Console .WriteLine ( "You should enter a double value." );
- goto begin1;
- }
- begin2:
- Console .WriteLine ( "Enter second number:" );
- if (! Double.TryParse ( Console .ReadLine (), out var2))
- {
- Console .WriteLine ( "You should enter a double value." );
- goto begin2;
- }
- if (var1 <var2)
- result = "less than" ;
- else
- {
- result = var1 == var2? "equal to" : "greater than" ;
- }
- Console .WriteLine ( "The first number is {0} the second number." , Result);
- Console .ReadKey ();
- }
* This source code was highlighted with Source Code Highlighter .
- static void Main ( string [] args)
- {
- const int fail = 10;
- int value = 0;
- switch ( value )
- {
- case 1:
- Console .WriteLine ( "This is one" );
- break ;
- case 2:
- Console .WriteLine ( "This is two" );
- break ;
- case fail:
- Console .WriteLine ( "This is fail" );
- break ;
- default :
- Console .WriteLine ( "This is default" );
- break ;
- }
- }
* This source code was highlighted with Source Code Highlighter .
- static void Main ( string [] args)
- {
- double balance = 0, interestRate = 0, targetBalance = 0;
- Console .WriteLine ( "What is your current balance?" );
- Double.TryParse ( Console .ReadLine (), out balance);
- Console .WriteLine ( "What is your current interest rate (in%)?" );
- Double.TryParse ( Console .ReadLine (), out interestRate);
- interestRate = 1 + interestRate / 100.0;
- Console .WriteLine ( "What balance would you like to have?" );
- Double.TryParse ( Console .ReadLine (), out targetBalance);
- int totalYears = 0;
- while (balance <targetBalance)
- {
- balance * = interestRate;
- totalYears ++;
- }
- Console .WriteLine ( "In {0} year {1} you will have a balance of {2}." , TotalYears,
- totalYears == 1? "" : "s" , balance);
- Console .ReadKey ();
Source: https://habr.com/ru/post/107957/
All Articles