Code Maze Author

Code Maze

This is the standard author on the site. Most articles are published by individual authors, with their profiles, but when several authors have contributed, we publish collectively as a part of this profile.
Also find me here:



MY ARTICLES:

How to Copy or Clone a List in C#

Copying a List<T> in C# is one expression: List<string> copy = [.. original]; gives us a new list holding the same elements. The List<T> constructor and LINQ's ToList() do exactly the same thing. [sc name="github"...

Refactoring Bloated Code in C#

In this article, we will learn what anti-patterns belong to the group of code smells called bloaters and different techniques for refactoring bloated code in C#. [sc name="github"...

How to Execute CLI Applications From C#

In this article, we will learn how to execute CLI applications in C# using a built-in class called Process and using open-source libraries. We will cover how we can execute CLI, how we can check if the CLI execution was successful, and how we can react to the...

Method Overriding in C#: override vs new

Method overriding is a derived class replacing a method it inherited. The base class marks the method virtual or abstract to permit it, the derived class marks its own version override, and from then on the object decides which implementation runs, not the variable...

How to Implement Checkbox List in ASP.NET Core

A Checkbox List is an important feature to encourage multiple selections of inputs in forms. We will start with a brief overview of the existing checkbox functionality in ASP.NET Core and later on move to the implementation of a checkbox list.  [sc name="github"...

JObject in C#: How to Get Value by Key

JObject is Json.NET's in-memory model of a JSON object, and it behaves like a dictionary: jsonObject["price"] hands back the value stored under that key. What comes back is a JToken, never a string or an int, so every read ends in a conversion. [sc...

How to Get an Enum Member as a String in C#

In this article, we're going to learn how to get a string representation of an enum member in C#. The possibility of defining enumeration types in C# - most widely known by the keyword enum - is a very useful feature. We can use them to assign named constants that...

Check If a String Array Contains a Value and Get Index

In this article, we are going to see the different ways we can check for a specific value in a string array and return the index of that value. We will focus mainly on linear search methods. We cannot use binary search methods since we do not know if the array is...

Required Members in C#

 C# 11 introduces the concept of required members. Any code instantiating the containing class must initialize these members; otherwise, the compiler will issue an error while compiling it. In this article, let's learn how to use this feature to prevent bugs and catch...

How to Randomize a List in C#

C# has several built-in methods for working with arrays and lists, but what if you need to randomize a list of items? In this article, we'll look at some techniques we can use to randomize lists in C#. We'll also discuss some of the pros and cons of each technique and...

How to Get The List of Properties in C#

In this article, we are going to learn how to get the list of properties in C#, and also how to use the BindingFlags to filter the properties to retrieve. [sc name="github"...

Convert String and Int to Enum in C#

Converting a string to an enum in C# is a call to Enum.Parse<T>() or Enum.TryParse<T>(). Converting an int to an enum is a cast. That asymmetry is the whole subject: one direction goes through a method that can reject bad input, and the other goes through...

Boxing and Unboxing in C#

In this article, we are going to talk about boxing and unboxing in C#.  When we work with C# language constantly, we need to...

Encrypting and Decrypting a String in C#

In this article, we will learn how encrypting and decrypting a string is done using C# and the Cryptography package that comes included with .NET. [sc name="github"...

Generic Attributes in C#

In this article, we are going to learn how generic attributes help us implement better custom attributes through a practical example. [sc name="github" url="https://github.com/CodeMazeBlog/CodeMazeGuides/tree/main/csharp-advanced-topics/GenericAttributesInCSharp"...

How to Iterate Over JSON Objects in C#

Manipulating JSON objects is a common operation in applications. In this article, we will look at different ways of iterating over JSON objects in C#. [sc name="github" url="https://github.com/CodeMazeBlog/CodeMazeGuides/tree/main/json-csharp/IteratingOverJsonObject"...