In this chapter we will cover the conditional statements in C#, which we can use to execute different actions depending on a given condition. We will explain the syntax of the conditional operators if and if-else with suitable examples and explain the practical application of the operator for selection switch-case.
This presentation is Unary operator overloading(prefix).
Here ,I try to describe how to Unary operator overloaded and its types with example. may be you can happily read this.
In this tutorial, you'll learn about conditional statements in C#. You'll understand if, else, else if and nested if else statements in C# along with their syntax. You will look at these basic concepts of C# programming with hands-on demos and examples.
INTRODUCTION
COMPARISON BETWEEN NORMAL FUNCTION AND INLINE FUNCTION
PROS AND CONS
WHY WHEN AND HOW TO USED?
GENERAL STRUCTURE OF INLINE FUNCTION
EXAMPLE WITH PROGRAM CODE
Python Exception Handling
This is a presentation to take your skills to next level. Hope you will like our work to make programming easier for you.
Feel free to contact for the online/offline batches.
This presentation is Unary operator overloading(prefix).
Here ,I try to describe how to Unary operator overloaded and its types with example. may be you can happily read this.
In this tutorial, you'll learn about conditional statements in C#. You'll understand if, else, else if and nested if else statements in C# along with their syntax. You will look at these basic concepts of C# programming with hands-on demos and examples.
INTRODUCTION
COMPARISON BETWEEN NORMAL FUNCTION AND INLINE FUNCTION
PROS AND CONS
WHY WHEN AND HOW TO USED?
GENERAL STRUCTURE OF INLINE FUNCTION
EXAMPLE WITH PROGRAM CODE
Python Exception Handling
This is a presentation to take your skills to next level. Hope you will like our work to make programming easier for you.
Feel free to contact for the online/offline batches.
Control structures in C++ Programming LanguageAhmad Idrees
The aim of this list of programming languages is to include all notable programming languages in existence, both those in current use and ... Note: This page does not list esoteric programming languages. .... Computer programming portal ...
17. Java data structures trees representation and traversalIntro C# Book
In this chapter we will discuss tree data structures, like trees and graphs. The abilities of these data structures are really important for the modern programming. Each of this data structures is used for building a model of real life problems, which are efficiently solved using this model.
In this chapter we will discuss one recommended practice for efficiently solving computer programming problems and make a demonstration with appropriate examples. We will discuss the basic engineering principles of problem solving, why we should follow them when solving computer programming problems (the same principles can also be applied to find the solutions of many mathematical and scientific problems as well) and we will make an example of their use. We will describe the steps, in which we should go in order to solve some sample problems and show the mistakes that can occur when we do not follow these same steps. We will pay attention to some important steps from the methodology of problem solving, that we usually skip, e.g. the testing. We hope to be able to prove you, with proper examples, that the solving of computer programming problems has a "recipe" and it is very useful.
In this chapter we review the basic rules and recommendations for writing quality program code. We pay attention to naming the identifiers in the program (variables, methods, parameters, classes, etc.), formatting and code organization rules, good practices for composing methods, and principles for writing quality documentation.
Here we are going to learn why is a good practice to use interfaces and how they are different from abstraction classes. Further more we are going to see how which one of them to use.
19. Java data structures algorithms and complexityIntro C# Book
In this chapter we will compare the data structures we have learned so far by the performance (execution speed) of the basic operations (addition, search, deletion, etc.). We will give specific tips in what situations what data structures to use.
In this chapter we will understand how to define custom classes and their elements. We will learn to declare fields, constructors and properties for the classes. We will revise what a method is and we will broaden our knowledge about access modifiers and methods.
In this chapter we will explore strings. We are going to explain how they are implemented in Java and in what way we can process text content. Additionally, we will go through different methods for manipulating a text: we will learn how to compare strings, how to search for substrings, how to extract substrings upon previously settled parameters and last but not least how to split a string by separator chars. We will demonstrate how to correctly build strings with the StringBuilder class. We will provide a short but very useful information for the most commonly used regular expressions.
In this chapter we will discuss exceptions in the object-oriented programming and in Java in particular. We will learn how to handle exceptions using the try-catch construct, how to pass them to the calling methods and how to throw standard or our own exceptions using the throw construct.
Here we are going to take a look how to use for loop, foreach loop and while loop. Also we are going to learn how to use and invoke methods and how to define classes in Java programming language.
03 and 04 .Operators, Expressions, working with the console and conditional s...Intro C# Book
In this chapter we will get acquainted with the operators in Java and the actions they can perform on the different data types. We will explain the priorities of the operators and we will analyze the different types of operators, according to the count of the arguments they can take and the actions they can perform. In the second part we will examine the conversion of data types.
In this chapter we will get familiar with primitive types and variables in Java – what they are and how to work with them. First we will consider the data types – integer types, real types with floating-point, Boolean, character, string and object type. We will continue with the variables, with their characteristics, how to declare them, how they are assigned a value and what is variable initialization.
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfFlorence Consulting
Quattordicesimo Meetup di Milano, tenutosi a Milano il 23 Maggio 2024 dalle ore 17:00 alle ore 18:30 in presenza e da remoto.
Abbiamo parlato di come Axpo Italia S.p.A. ha ridotto il technical debt migrando le proprie APIs da Mule 3.9 a Mule 4.4 passando anche da on-premises a CloudHub 1.0.
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBrad Spiegel Macon GA
Brad Spiegel Macon GA’s journey exemplifies the profound impact that one individual can have on their community. Through his unwavering dedication to digital inclusion, he’s not only bridging the gap in Macon but also setting an example for others to follow.
Italy Agriculture Equipment Market Outlook to 2027harveenkaur52
Agriculture and Animal Care
Ken Research has an expertise in Agriculture and Animal Care sector and offer vast collection of information related to all major aspects such as Agriculture equipment, Crop Protection, Seed, Agriculture Chemical, Fertilizers, Protected Cultivators, Palm Oil, Hybrid Seed, Animal Feed additives and many more.
Our continuous study and findings in agriculture sector provide better insights to companies dealing with related product and services, government and agriculture associations, researchers and students to well understand the present and expected scenario.
Our Animal care category provides solutions on Animal Healthcare and related products and services, including, animal feed additives, vaccination
1.Wireless Communication System_Wireless communication is a broad term that i...JeyaPerumal1
Wireless communication involves the transmission of information over a distance without the help of wires, cables or any other forms of electrical conductors.
Wireless communication is a broad term that incorporates all procedures and forms of connecting and communicating between two or more devices using a wireless signal through wireless communication technologies and devices.
Features of Wireless Communication
The evolution of wireless technology has brought many advancements with its effective features.
The transmitted distance can be anywhere between a few meters (for example, a television's remote control) and thousands of kilometers (for example, radio communication).
Wireless communication can be used for cellular telephony, wireless access to the internet, wireless home networking, and so on.
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC
Ellisha Heppner, Grant Management Lead, presented an update on APNIC Foundation to the PNG DNS Forum held from 6 to 10 May, 2024 in Port Moresby, Papua New Guinea.
2. 2
1. Comparison and Logical Operators
2. The if Statement
3. The if-else Statement
4. Nested if Statements
5. The switch-case Statement
Table of Contents
4. 4
Operator Notation in C# Applicable for
Equals == strings / numbers /
dates / most objectsNot Equals !=
Greater Than >
numbers / dates /
comparable objects
Greater Than or Equals >=
Less Than <
Less Than or Equals <=
Comparison Operators
bool result = (5 <= 6);
Console.WriteLine(result); // True
Example:
5. 5
De Morgan laws
!!A A
!(A || B) !A && !B
!(A && B) !A || !B
Logical Operators
Operator Notation in C# Example
Logical NOT ! !false true
Logical AND && true && true true
Logical OR || true || false true
Logical Exclusive OR (XOR) ^ true ^ false true
7. 7
The most simple conditional statement
Enables you to test for a condition
Branch to different blocks in the code depending on the result
The simplest form of the if statement:
The if Statement
if (condition)
{
statements;
}
8. 8
The condition can be:
Boolean variable
Boolean logical expression
Comparison expression
The condition cannot be integer variable (like in C / C++)
The statement can be:
Single statement ending with a semicolon
Block enclosed in curly braces
Condition and Statement
9. 9
The condition is evaluated
If it is true, the statement is executed
If it is false, the statement is skipped
How It Works?
true
condition
statements
false
10. 10
The if Statement – Example
static void Main()
{
Console.WriteLine("Enter two numbers.");
int biggerNum = int.Parse(Console.ReadLine());
int smallerNum = int.Parse(Console.ReadLine());
if (smallerNum > biggerNum)
{
biggerNum = smallerNum;
}
Console.WriteLine("The greater number is: {0}", biggerNum);
}
12. 12
More complex and useful conditional statement
Executes one branch if the condition is true, and another if it is false
The simplest form of an if-else statement:
The if-else Statement
if (expression)
{
some_statement;
}
else
{
another_statement;
}
13. 13
The condition is evaluated
If it is true, the first statement is executed
If it is false, the second statement is executed
How It Works?
condition
first
statement
true
second
statement
false
14. 14
Checking a number if it is odd or even
if-else Statement – Example
string s = Console.ReadLine();
int number = int.Parse(s);
if (number % 2 == 0)
{
Console.WriteLine("This number is even.");
}
else
{
Console.WriteLine("This number is odd.");
}
17. 17
if and if-else statements can be nested
Used inside one inside another
Each else corresponds to its closest preceding if
Nested if Statements
if (expression)
{
if (expression)
some_statement;
else
another_statement;
}
else
third_statement;
18. 18
Always use { … } blocks to avoid ambiguity
Even when a single statement follows
Avoid using more than three levels of nested if statements
Put the case you normally expect to process first
Then write the unusual cases
Arrange the code to make it more readable
Nested if – Good Practices
19. 19
Nested if Statements – Example
if (first == second)
{
Console.WriteLine("These two numbers are equal.");
}
else
{
if (first > second)
{
Console.WriteLine("The first number is bigger.");
}
else
{
Console.WriteLine("The second is bigger.");
}
}
21. 21
We may need to use another if-construction in the else block
Thus else if can be used:
Multiple if-else-if-else-…
int ch = 'X';
if (ch == 'A' || ch == 'a')
{
Console.WriteLine("Vowel [ei]");
}
else if (ch == 'E' || ch == 'e')
{
Console.WriteLine("Vowel [i:]");
}
else if …
else …
24. 24
Selects for execution a statement from a list depending on the
value of the switch expression
The switch-case Statement
switch (day)
{
case 1: Console.WriteLine("Monday"); break;
case 2: Console.WriteLine("Tuesday"); break;
case 3: Console.WriteLine("Wednesday"); break;
case 4: Console.WriteLine("Thursday"); break;
case 5: Console.WriteLine("Friday"); break;
case 6: Console.WriteLine("Saturday"); break;
case 7: Console.WriteLine("Sunday"); break;
default: Console.WriteLine("Error!"); break;
}
25. 25
1. The expression is evaluated
2. When one of the constants specified in a case label is equal to
the expression
The statement that corresponds to that case is executed
3. If no case is equal to the expression
If there is default case, it is executed
Otherwise the control is transferred to the end point of the
switch statement
How switch-case Works?
27. 27
Variable types like string, enum and integral types can be used
for switch expression
The value null is permitted as a case label constant
The keyword break exits the switch statement
"No fall through" rule
You are obligated to use break after each case
Multiple labels that correspond to the same statement are
permitted
Using switch: Rules
28. 28
Multiple labels allow matching several cases and executing the
same statement in more than one case
Multiple Labels – Example
switch (animal)
{
case "dog":
Console.WriteLine("MAMMAL");
break;
case "crocodile":
case "tortoise":
case "snake":
Console.WriteLine("REPTILE");
break;
default:
Console.WriteLine("I don't know such animal!");
break;
}
30. 30
There must be a separate case for every normal situation
Put the normal case first
Put the most frequently executed cases first and the least
frequently executed last
Order cases alphabetically or numerically
In default use case that cannot be reached under normal
circumstances
Using switch – Good Practices
31. 31
Comparison and logical operators are used to compose logical
conditions
The conditional statements if and if-else
conditionally execution of blocks of code
Constantly used in computer programming
Conditional statements can be nested
The switch statement easily and elegantly checks an
expression for a sequence of values
Summary
33. License
This course (slides, examples, demos, videos, homework, etc.)
is licensed under the "Creative Commons Attribution-
NonCommercial-ShareAlike 4.0 International" license
33
Attribution: this work may contain portions from
"Fundamentals of Computer Programming with C#" book by Svetlin Nakov & Co. under CC-BY-SA license
"C# Part I" course by Telerik Academy under CC-BY-NC-SA license
34. Free Trainings @ Software University
Software University Foundation – softuni.org
Software University – High-Quality Education,
Profession and Job for Software Developers
softuni.bg
Software University @ Facebook
facebook.com/SoftwareUniversity
Software University @ YouTube
youtube.com/SoftwareUniversity
Software University Forums – forum.softuni.bg
Editor's Notes
(c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
(c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
(c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
(c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
(c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
(c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
(c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
(c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*