Want to create interactive content? It’s easy in Genially!

Reuse this genially

c#

Derick Rojas Hernandez

Created on September 6, 2023

Start designing with a free template

Discover more than 1500 professional designs like these:

Transcript

Derick Rojas Hernandez

09/07/2023

Intoduccion a la Programacion

Microsot team lead by Anders Hejlsberg. June 2000

Variable

How to declare a Variable?

How declare a variable you have to choose the type of variable first and then assign the value

  • int - stores integers (whole numbers), without decimals, such as 123 or -123
  • string - stores text, such as "Hello World". String values are surrounded by double quotes

EXAMPLE: type variableName = value;

Constant

How to declare a constant?

Example const int myNum = 15; myNum = 20; // error

If you do not want a value on your code to be changed by you or someone else you can declare a constant to have the same value. On C# it will be used const.

If/else

How to declare and use conditions (if/else statement)

int time = 20; if (time < 18) { Console.WriteLine("Good day."); } else { Console.WriteLine("Good evening."); } // Outputs "Good evening."

Use the if statement to specify a block of C# code to be executed if a condition is True.

Use the else statement to specify a block of code to be executed if the condition is False.

While/For

Loops while and for

Iterator

Condition

Initialization

If the condition is evaluated to true: a. The statements inside the for loop are executed. b. Then, the iterator statement is executed which usually changes the value of the initialized variable. c. Again the condition is evaluated. d.The process continues until the condition is evaluated to false. If the condition is evaluated to false, the for loop terminates.

Then, the condition is evaluated. The condition is a boolean expression, i.e. it returns either true or false.

The initialization statement is executed at first and only once. Here, the variable is usually declared and initialized.

For loop

for (int i = 0; i < 5; i++) { Console.WriteLine(i); }

While loop

int i = 0; while (i < 5) { Console.WriteLine(i); i++; }

FUNCTIONS

Functions

Functions are also called modules or procedures. Instead of writing a single main program, i.e., everything inside the main function, we can break the main function into small manageable size pieces and separate the repeating tasks or smaller tasks as a function.

Función La función devuelve un resultado al código invocante. La ejecución de return provoca la salida de la función. int calculo () { ... instrucciones ... return resultado;

OOP

Object Oriented Programming

Procedural programming is about writing procedures or methods that perform operations on the data, while object-oriented programming is about creating objects that contain both data and methods.

Object-oriented programming has several advantages over procedural programming: OOP is faster and easier to execute OOP provides a clear structure for the programs OOP helps to keep the C# code DRY "Don't Repeat Yourself", and makes the code easier to maintain, modify and debug OOP makes it possible to create full reusable applications with less code and shorter development time

Thanks