Select language
Română
English
Français
Deutsch
Italiano
Español
Home
Languages ▾
CPP
C
CS
GO
JAVA
Python
Html
JS
CSS
PHP
Hard Lessons ▾
Hard Lesson 1
Hard Lesson 2
Hard Lesson 3
Hard Lesson 4
Hard Lesson 5
Hard Lesson 6
Hard Lesson 7
Hard Lesson 8
Hard Lesson 9
Hard Lesson 10
Hard Lesson 11
Hard Lesson 12
Compiler
Account
CS/C#
Example
using System; class Program { static void Main() { int n; Console.Write("Input: "); n = int.Parse(Console.ReadLine()); Console.WriteLine("You entered: " + n); } } OUTPUT: Input: 5 You entered: 5
Variables
- int - EX: 100 - Size: 4 bytes - float - EX: 5.67f - Size: 4 bytes - double - EX: 5.678 - Size: 8 bytes - char - EX: 'A' - Size: 2 bytes - string - EX: "Hello" - Size: depends on content - bool - EX: true/false - Size: 1 byte - long - EX: 1000000L - Size: 8 bytes - short - EX: 100 - Size: 2 bytes - decimal - EX: 10.5m - Size: 16 bytes
Input
int number; Console.Write("Enter number: "); number = int.Parse(Console.ReadLine()); Console.WriteLine("Number: " + number); char character; Console.Write("Enter character: "); character = char.Parse(Console.ReadLine()); Console.WriteLine("Character: " + character);
Output
Console.WriteLine("text"); Console.WriteLine(variable); Console.Write("Same line "); Console.WriteLine(); // Empty line Console.WriteLine('A'); Console.WriteLine((char)65); // Outputs: A Console.WriteLine("Hello\tWorld"); // Tab Console.WriteLine("Line1\nLine2"); // New line
Comments
// This is a single-line comment /* This is a multi-line comment Spans multiple lines */
Functions
static int Add(int a, int b) { return a + b; } // Usage: int result = Add(5, 3); Console.WriteLine(result); // void function (no return) static void Greet(string name) { Console.WriteLine("Hello " + name); }