Thursday, October 18, 2018 21:17

Conditional statement If-Else

January 8th, 2017

In addition to If, C# offers conditional statement If-Else. When I explained the If statement, I was saying that the program will execute the instructions only if the If condition is True. What if we wanted to execute a total different condition when and only when that condition is False?… Read more

Testing a condition with If

January 7th, 2017

As previously stated in our lessons, as your programs will become more and more complex, they will perform a set of instructions when a condition is True, and another one when is False. When your program executes a conditional processing, you will be testing a condition with If.… Read more

Representation of True and False values

January 7th, 2017

A few lessons so far dealt with conditional processing, displaying a result when a condition is true, and another when it is false. When working with conditional processing, it is important to understand the representation of True and False values in C#.… Read more

Conditional processing

January 7th, 2017

Now that we are done with data types, we can finally start learning about doing something useful with that data. Conditional processing is one of the most basic forms of allowing your programs to perform an useful action.

As you noticed, all the programs presented so far in our lessons started the execution with the Main method, and continued subsequently with the following instructions.… Read more

Conversion to type String

January 7th, 2017

The first kind of conversion to type string is the implicit type converting. Whenever you concatenate a string and another type which is not of type string, the .NET runtime will convert the second type to string, on the fly, in behind, without you knowing it.… Read more

Explicit type conversion

January 6th, 2017

Explicit type conversion basically means “I know what I am doing, so let me covert this into this, because I know it will work”. It is used whenever there is a possibility of data loss. For instance, when converting from ANY real number type into an integer, there is ALWAYS a loss of data, because integers cannot store fractional parts.… Read more

Implicit type conversion

January 6th, 2017

As we discussed in the last lesson, implicit type conversion (hidden conversion) is only possible when there is no risk of any data loss during the transformation (for instance, when converting a lower range number, like an int, to a higher range number, like a long).… Read more

Casting and type conversion

January 6th, 2017

Casting and type conversion generally refers to modifying a data type into another data type. In order to perform an operation on two data types, we need to convert both to the same data type. Type conversion if of two kinds: implicit and explicit.Read more

Other operators

January 6th, 2017

Aside of the operators I have enumerated so far, there are a few other operators that are either too simple, too rarely used or too unimportant to create additional posts for them.

The . (dot) operator. We’ve used it quite a lot so far (remember Console.WriteLine?).… Read more

Conditional operator

January 6th, 2017

Conditional operator is a bit harder to explain. It takes an expression which produces a Boolean result in order to determine which of two other expressions will be calculated and have its value returned as a result. Its sign is ?:.… Read more