Friday, April 19, 2024 15:54

Archive for April, 2017

Substring

Friday, April 21st, 2017

A substring is a string located inside another string. To extract a portion of a string (substring), we can use the Substring() method, with some additional parameters, such as the starting index and the character count or length. Whenever the length parameter is omitted, the function will simply return the substring that starts at the specified index until the end of the string.… Read more

Searching for a string within another string

Friday, April 21st, 2017

Another very useful operation when dealing with text is the searching of a certain string or letter inside another string. There are multiple ways of accomplishing this, each behaving in a different way.

The first function that we can use to perform a search is Contains().… Read more

UPPERCASE and lowercase

Friday, April 21st, 2017

There are times when we need to convert the letters of a string to either uppercase or lowercase. Fortunately, C# offers us two methods for this: ToUpper() and ToLower().  As imagined, the first one will convert all letters of a string into capital letters, while the latter will do the opposite, by converting them to small ones.… Read more

Concatenation

Friday, April 21st, 2017

Since now we know the fundamentals about strings and their structure, it is time to learn about the various operations we can perform on them. The simplest of these operation is concatenation, or joining two or more strings together and obtaining a new string as a result.… Read more

Strings

Friday, April 21st, 2017

So far, we have often used Console.ReadLine() in our Console programs, in order to get some text input from the user. Whenever we needed to use that text (and even inspecting the Console.ReadLine() method signature), we needed to store that text in a string variable type.… Read more

Recursive functions

Thursday, April 20th, 2017

Recursion is a mathematical concept that defines any object that is contained or defined by itself. That should be the official, academic definition. In simple words, recursive functions are functions that make a call to themselves from within their own body, in order to solve a problem.… Read more

Best practices when using methods and functions

Wednesday, April 19th, 2017

There are two main reasons why methods and functions are even used. First one, which I already mentioned in a few of the previous posts, is code re-usability. The second is modularization of the code, splitting of complex tasks into smaller sub-tasks, which can offer us a better overview of the entire functionality.… Read more

Return operator

Tuesday, April 18th, 2017

In few of our previous lessons, we used functions – methods that not only can be called, perform some action, but also return a value to the caller – the piece of code that called them. You can imagine this as placing the returned value in the place where the function was invoked from.… Read more

Methods and functions signature

Monday, April 17th, 2017

I talked in the previous lesson about methods and functions signatures, and I offered there a brief explanation on the topic. It is time to explain this new concept in more detail. At a basic level, there are only two things that are mandatory to specify a method or function signature: the parameters type and the order in which the parameters are listed.… Read more

Functions and methods overloading

Monday, April 17th, 2017

There are times when we have functions or methods that perform basically the same thing, but use different kind of parameters. So, in other words, there are cases when we have methods with the same name, but with different signatures.… Read more


Follow the white rabbit