As we saw in the previous recent lessons, the usual way of communicating with a class is to create instances (copies) of it, and then use the resulting objects. In fact, that is the strong advantage of the classes – the ability to create copies that can be used and can be modified individually.… Read more
Static members
May 18th, 2017Access modifiers
May 14th, 2017As their name suggests, access modifiers are some programming concepts that can alter the access level of something. In more complex words, access modifiers are reserved keywords which add information for the compiler, and the piece of code related to those modifiers.… Read more
Instantiation
April 26th, 2017I have explained a few times already that when we are dealing with objects, most of the times we are not working with the original class itself – the blueprint, but we are actually create copies of it called instances.… Read more
Constructors
April 25th, 2017In object-oriented programming, when creating objects from given classes, it is sometimes necessary to call some special methods of those classes, known as a constructors.
Constructor of a class is a pseudo-method, which does not have a return type, has the name of the class and is called using the keyword new.… Read more
Properties
April 23rd, 2017In today’s lesson, I will talk about one of the previous lesson’s new concepts. The first subject on the list: fields and properties. According to our beloved MSDN, a property is a member that provides a flexible mechanism to read, write, or compute the value of a private field.… Read more
Classes
April 22nd, 2017At a definition level, classes are objects defined by the keyword class, followed by an identifier (name) and a body (code block), which contains the codes that define the object and its behavior.
Most of the times, classes can contain only four kind of elements:
- Fields – member variables of a certain type, defined at class level
- Properties – a special kind of programming constructs which helps us manipulate the fields, and set the properties of the object
- Methods – they implement the functionality of the object.
Object oriented programming
April 22nd, 2017Object oriented programming (OOP) is a programming paradigm, which uses objects and their interactions for building computer programs.
Through this concept, programming tries to simulate the real world. In real world, we can have objects like a car, an orange, a dog.… Read more
String Builder
April 21st, 2017I was explaining at some point that string is an immutable type. That means that once you assign a value to a string variable, you cannot directly modify it anymore. This also means that any string operation using any function such as Trim(), Replace(), ToUpper(), etc, will actually create a new string in memory where the resulting value will be stored, and it will delete the old, initial value. … Read more
Other string methods
April 21st, 2017There are a number of other string methods that you might find useful. They are:
Compare(), CompareTo(), CompareOrdinal() – determines the sort order of strings. It checks if one string is ordered before another when in alphabetical order, whether it is ordered after, or is equivalent.… Read more
Replacing a string inside another string
April 21st, 2017Whenever you want to replace a string inside another string, .NET Framework offers the Replace() function. It is a function that accepts two string parameters, the string to be replaced and the string to replace with. Its usage is very simple:
using System; namespace HelloWorld { class Program { private static void Main(string[] args) { string greeting = "Hello World!";… Read more