You are on page 1of 10

C# - Programming language we use.

Visual Studio – Compiler we use.


C# Shell – Mobile phone compiler.
Static - Static variables are shared among all instances of the class and are
initialized only once, typically at the start of the program.
Dynamic - Dynamic typing allows for more flexibility because the type of a variable
can change during the execution of the program.

Using Statements;
using System; - This imports the entire ‘System’ namespace, which contains
fundamental types and base classes that define commonly-used value and reference
data types, events and event handlers, interfaces, attributes, and processing
exceptions.
using System.Collections.Generic; - This imports the ‘System.Collections.Generic’
namespace, which contains interfaces and classes that define generic collections,
which allow for type-safe data structures without boxing and unboxing to and from
objects.
using System.Linq; - This imports the ‘System.Linq’ namespace, which provides
classes and interfaces that support queries that use Language-Integrated Query
(LINQ). LINQ enables you to query collections in a more expressive and concise
manner.
using System.Text; - This imports the ‘System.Text’ namespace, which contains
classes representing ASCII, UTF-8, UTF-16, and UTF-32 characters encodings,
along with classes for converting blocks of characters to and from blocks of bytes.
using System.Threading.Tasks;: This imports the ‘System.Threading.Tasks’
namespace, which provides types that simplify the work of writing concurrent and
asynchronous code. It includes the Task and Task<TResult> classes, which
represent asynchronous operations.
Method Calls:
Console.Writeline(); - Method used to display a text on the console command line
interface.

Console.ReadKey(); - Is a method used to read the next key of character pressed


by the user from the console or command line interface. It allows programs to wait
for user input and the continue execution based on the input.

Console.Write(); - This method writes the specified string or object to the console
without appending a newline character.

Console.Readline(); - used to read a line of text input from the console or command
line interface. It allows the program to wait for the user to input text and then
captures that text for further processing.
Comments:
are used for noting how your code functions/works (the compiler won’t read
comments).
// - Single line comment.

/* */ - Multi line comment.

Data Types:
After we put a data type, the next is the variable name which will be the container.
String – Stores texts (many characters) and must always be inside a double
quotation.

int - is a keyword used to declare a variable that can hold integer values.
Keywords:
Out - is a keyword used in method parameters to indicate that the corresponding
argument is an output parameter. When you use out in a method parameter
declaration, you're telling the compiler that the method will assign a value to that
parameter, and that value will be accessible to the caller after the method completes
execution.
, - serves multiple purposes depending on the context in which it is used. Here are
some common uses.
+ - When used with string operands, the + operator concatenates (joins together) the
strings.
break - is used within control flow statements, such as switch, for, while, and do-
while loops, to exit the current loop or switch block prematurely. Its usage varies
depending on the context.
Index - allows you to access elements in a collection using a simplified syntax. It's
particularly useful when working with data structures like arrays, lists, or custom
collections. Indexes always starts at 0.
return - used to exit a method and optionally return a value to the caller. When a
return statement is encountered within a method, the execution of the method is
immediately terminated, and control is returned to the calling code.
in - used as a modifier for parameters in method signatures. It indicates that an
argument is passed by reference, but it's considered read-only within the method.
Conversion:
.ToString(); - is a method that belongs to all objects. It converts the value of the
current object to its string representation.

int.Parse(); - is a method used to convert a string representation of a number into its


equivalent integer representation.
int.TryParse(); - is a method used to attempt to parse a string representation of a
number into its equivalent integer representation without throwing an exception.
Instead of raising an exception like int.Parse does when parsing fails, int.TryParse
returns a boolean value indicating whether the parsing operation was successful or
not.

Arithmetic Operators:
+ - Adds two operands.
- - Subtracts the second operand from the first operand.
* - Multiplies two operands.
/ - Divides first operand by the second operand.
% - Computes the remainder of the division of the first and second operand.
++ - Increments the value of operand by 1.
— - Decrements the value of operand by 1

Relational Operators:
== - Returns true if the two operands are equal, otherwise returns false.
!= - Returns true if the two operands are not equal, otherwise returns false.
> - Returns true if the left operand is greater than the right operand, otherwise
returns false.
< - Returns true if the left operand is less than the right operand, otherwise returns
false.
>= - Returns true if the left operand is greater than or equal to the right operand,
otherwise returns false.
<= - Returns true if the left operand is less than or equal to the right operand,
otherwise returns false.
Logical Operators:
&& - Returns true if both operands are true, otherwise returns false.
|| - Returns true if at least one of the operands is true, otherwise returns false.
! - Returns true if the operand is false, and false if the operand is true.

Control Flow Statements:


if Statement
if - The if statement is used to execute a block of code if a specified condition is true.
else if - The else if statement is used to specify a new condition to test if the first
condition in the if statement is false.
else - The else statement is used to execute a block of code if the specified
condition in the if statement is false.

Switch Statement - is a
control flow statement used to
select one of many code
blocks to be executed based
on the value of an expression.
It's an alternative to using
multiple if...else if...else
statements when you have
multiple conditions to check.
Array - a fixed-size collection of elements of the same type. It provides a convenient
way to store and access multiple values of the same data type sequentially. Arrays
are zero-indexed, meaning the index of the first element is 0, the second element is
1, and so on.

Loops:
for loop - used for iterating over a range of values or elements. It allows you to
execute a block of code repeatedly until a specified condition is met.

while loop - repeatedly executes a block of code as long as a specified condition is


true. Unlike a for loop, which is typically used when the number of iterations is known
beforehand, a while loop is more flexible and is used when the number of iterations
is not known in advance.

do while loop - executes a block of code once before checking if a specified


condition is true. If the condition is true, the loop continues to execute the block of
code repeatedly. Unlike the while loop, a do-while loop always executes its body at
least once.
foreach - is a specialized type of loop used for iterating over elements in a collection
or an array. It simplifies the process of iterating through each element of a collection
without needing to manually manage indices or counters. The foreach loop iterates
over each element of the collection sequentially until all elements have been
processed.

List - It allows you to store and manipulate a collection of elements of a specific


type, similar to an array. However, unlike arrays, lists can dynamically grow or shrink
in size as needed, making them more flexible for storing and working with collections
of data.

Method:
Methods are used to make our line of codes shorter.
Main Method - is the entry point of a C# console application. When you run a C#
console application, the runtime system looks for the Main method as the starting
point for the program's execution. The Main method must be declared as static, and
it serves as the program's starting point from which other methods can be invoked.

Method - a code block that contains a series of statements to perform a specific task
or operation. Methods are fundamental building blocks of C# programs, and they
help organize code into reusable units, improve code readability, and facilitate code
maintenance.

You might also like