Author: Marinko Spasojevic

C# Back to Basics – Working With Files, File and Directory

File and Directory classes contain different static methods for manipulating the files, directories, and subdirectories. These classes exist in the System.IO namespace. So, let’s inspect some of the most used methods of both classes. For the complete navigation of this series check out: C# Back to Basics. File Methods WriteAllText(string path, string contents) creates a new file and writes content to that file. If the target file already exists, it will overwrite it: C# 123 string path = @"C:\FileExamples\test.txt";string content = "Example content as a string message";File.WriteAllText(path, content); WriteAllLines(string path, string[] contents) creates a new file and writes a...

Read More

C# Back to Basics – Working With Files, StreamWriter and StreamReader

It’s time to learn how to work with files in C#. For that purpose, in this article, we will cover two classes StreamWriter and StreamReader. For the complete navigation of this series check out: C# Back to Basics. If you want to download the source code for our examples, you can do that from here StreamWriter and StreamReader C# Source Code. The StreamReader and StreamWriter classes enable the reading and writing actions to a file. Both of these classes exist in the System.IO namespace as well as many other classes for working with files and directories. We are going...

Read More

C# Back to Basics – Arrays in C#

We often have a situation where we need to use a couple variables of the same type and to execute the same operation on each of them. Imagine if we need hundreds of variables or even more, well we can agree upon a fact that creating a hundred variables of the same type is not a solution. Fortunately, C# provides us with the complex type named array. For the complete navigation of this series check out: C# Back to Basics. To download the source code, visit Arrays in C# Source Code. Arrays are the reference data types that consist...

Read More

C# Back to Basics – Recursion and Recursive Methods

In this article, we are going to talk about Recursion and Recursive Methods in C#. Furthermore, we will learn how to use recursive methods and how they differ from the regular methods. For the complete navigation of this series check out: C# Back to Basics. If you want to download the source code for our examples, you can do that from here Recursive Methods in C# Source Code. So what is recursion? Recursion is a concept in which method calls itself. Every recursive method needs to be terminated, therefore, we need to write a condition in which we check...

Read More

C# Back to Basics – Ref and Out Keywords in C#

In this article, we are still going to talk about methods but from a different perspective. We are going to learn how to pass our arguments by using the ref and out keywords. For the complete navigation of this series check out: C# Back to Basics. If you want to download the source code for our examples, you can do that from here Ref and Out Keywords Source Code. This article is divided into several sections: Using Ref and Out Keywords Example 1 for the Value Type Example 2 for the Reference Type Conclusion In the previous post, we...

Read More