From f8226f72d6732651cf05dd7fe596d01bb88cdcc2 Mon Sep 17 00:00:00 2001 From: Joe Roland Date: Mon, 21 Jan 2019 13:07:27 -0500 Subject: [PATCH] fix(guide): Fixed code block formatting (#28994) --- .../the-c-programming-language/index.md | 132 ++++++++++-------- 1 file changed, 72 insertions(+), 60 deletions(-) diff --git a/guide/english/miscellaneous/the-c-programming-language/index.md b/guide/english/miscellaneous/the-c-programming-language/index.md index aa640ad7ac..1047e4696f 100644 --- a/guide/english/miscellaneous/the-c-programming-language/index.md +++ b/guide/english/miscellaneous/the-c-programming-language/index.md @@ -59,30 +59,32 @@ Alternatively, you could also download Main method which is the entry point of the program. @@ -101,11 +103,13 @@ C# is a strongly typed language. Every variable has a type. Every expression or Edit in .NET Fiddle - int a = 10; - int b = 20; - a=b; - Console.WriteLine(a); //prints 20 - Console.WriteLine(b); //prints 20 +```C# +int a = 10; +int b = 20; +a=b; +Console.WriteLine(a); //prints 20 +Console.WriteLine(b); //prints 20 +``` Note that in other dynamic languages this could be different, but in C# this is always a value copy. When value type is created, a single space most likely in stack is created, which is a "LIFO" (last in, first out) data structure. The stack has size limits and memory operations are efficient. Few examples of built-in data types are `int, float, double, decimal, char and string`. @@ -134,28 +138,31 @@ More information If else statement : Edit in .NET Fiddle - int myScore = 700; - if (myScore == 700) - { - Console.WriteLine("I get printed on the console"); - } - else if (myScore > 10) - { - Console.WriteLine("I don't"); - } - else - { - Console.WriteLine("I also don't"); - } + ```C# + int myScore = 700; + if (myScore == 700) + { + Console.WriteLine("I get printed on the console"); + } + else if (myScore > 10) + { + Console.WriteLine("I don't"); + } + else + { + Console.WriteLine("I also don't"); + } - /** Ternary operators - A simple if/else can also be written as follows - ? : **/ - int myNumber = 10; - string isTrue = myNumber == 10 ? "Yes" : "No"; + /** Ternary operators + A simple if/else can also be written as follows + ? : **/ + int myNumber = 10; + string isTrue = myNumber == 10 ? "Yes" : "No"; + ``` * Switch statement : Edit in .NET Fiddle + ```C# using System; public class Program @@ -189,9 +196,11 @@ More information For & Foreach : Edit in .NET Fiddle + ```C# for (int i = 0; i < 10; i++) { Console.WriteLine(i); //prints 0-9 @@ -210,28 +219,31 @@ More information While & do-while : Edit in .NET Fiddle + ```C# // Continue the while-loop until index is equal to 10. - int i = 0; - while (i < 10) - { - Console.Write("While statement "); - Console.WriteLine(i);// Write the index to the screen. - i++;// Increment the variable. - } + int i = 0; + while (i < 10) + { + Console.Write("While statement "); + Console.WriteLine(i);// Write the index to the screen. + i++;// Increment the variable. + } - int number = 0; - // do work first, until condition is satisfied i.e Terminates when number equals 4. - do - { - Console.WriteLine(number);//prints the value from 0-4 - number++; // Add one to number. - } while (number <= 4); \ No newline at end of file + int number = 0; + // do work first, until condition is satisfied i.e Terminates when number equals 4. + do + { + Console.WriteLine(number);//prints the value from 0-4 + number++; // Add one to number. + } while (number <= 4); + ``` +