Author: Marinko Spasojevic

C# Intermediate – Abstract Classes in C#

Different classes may implement the same interface, and that is the common case in a software development. What is common as well is that the method from that interface can have the same implementation in those classes. That could be a signal that we are doing something wrong. We don’t want to repeat the code in our classes, but to reuse the common implementation. To fix this, we can extract this common implementation to a base class, and make our classes implement a base class and then make the base class implement an interface. This will solve our problem,...

Read More

C# Intermediate – Interfaces in C#

Inheriting from a class is a powerful mechanism, but the real inheritance power comes from an interface. An interface provides the members that a class which inherits from an interface must implement. We can look at the interface as a contract which states that a class that implements an interface must implement all the members from it. If you want to see complete navigation of this tutorial, you can do that here C# Intermediate Tutorial. To download the source code, you can visit Interfaces in C# Source Code.  We are going to split this article into the following sections:...

Read More

C# Intermediate – Inheritance in C#

Inheritance is one of the three key concepts in an object-oriented programming. We can use inheritance to avoid repetition when different classes have a number of features in common and are related to each other. In this post, we are going to talk about C# inheritance, why is it important and what we can use it for. If you want to see complete navigation of this tutorial, you can do that here C# Intermediate Tutorial. To download the source code, you can visit Inheritance in C# Source Code.  We are going to split this article into the following sections:...

Read More

C# Intermediate – Enumerations in C#

Besides the structures, C# supports another value type Enumeration. In this article, we are going to talk more about Enumerations in C#. If you want to see complete navigation of this tutorial, you can do that here C# Intermediate Tutorial. To download the source code, you can visit Enumerations in C# Source Code.  We are going to split this article into the following sections: Working with Enumerations Choosing Enumeration Literal Values Choosing an Enumerations Underlying Type Conclusion Working with Enumerations in C# Suppose we need to represent days in a week in our C# project. We can use an...

Read More

C# Intermediate – Structures in C#

In the previous articles, we have learned about classes, how to use them and how to create an object as an instance of a class. In this article, we are going to talk about structures which are similar to classes but have some differences as well. If you want to see complete navigation of this tutorial, you can do that here C# Intermediate Tutorial. To download the source code, you can visit Structures in C# Source Code.  We are going to split this article into the following sections: Working with Structures Structure Declaration Differences Between Classes and Structures When...

Read More