C# Code Snippets IEnumerable IEnumerator and Yield

C# IEnumerable and IEnumerator

In this tutorial, we will take a look at the IEnumerator and IEnumerable in C#. Making an object enumerable will allow us to iterate over it with something like the foreach loop. IEnumerable is an interface that specifies what has to be implemented to make an object iterable(an object that can be iterated over). For an object to be iterable it has to have a GetEnumerator() method that returns an object of type IEnumerator.

C# Code Snippets JSON Serialization

C# JSON Serialization

In this tutorial, we will learn about JSON serialization in C#. Serialization is when you take an object and convert it to a stream of bytes that can be then stored in a file, database or memory. This is useful if you want to store the state of your objects or send them over the network(for example an API). Of course, you can also deserialize a file/database entry back into an object.

C# Code Snippets Binary Serialization

C# Binary Serialization

In this tutorial, we will learn about binary serialization in C#. Serialization is when you take an object and convert it to a stream of bytes that can be then stored in a file, database or memory. This is useful if you want to store the state of your objects or send them over the network(for example an API). Of course, you can also deserialize a file/database entry back into an object. 

C# Code Snippets XML Serialization

C# XML Serialization

In this tutorial, we will learn how to do XML serialization in C#. Serialization is when you take an object and convert it to a stream of bytes that can be then stored in a file, database or memory. This is useful if you want to store the state of your objects or send them over the network(for example an API). Of course, you can also deserialize a file/databese entry back into an object. We will alos se how to do that.

C# Code Snippets as operator

C# as Operator

In this tutorial, we will learn how to use the as operator in C#. The as operator is used to cast objects into different types. It is similar to the is operator. They can both be used to check if an object is of a certain type. If the conversion is successful the converted object gets returned else a null will be returned.

C# Code Snippets is operator

C# is Operator

In this tutorial, we will learn how to use the is operator in C#. The is operator is very similar to the as operator. They can both be used to check if an object is of a certain type. Additionally as can be used to perform type casting. If the object matches the specified data type true gets returned else false will be returned.

C# Code Snippets Conversion Operator Overloading

C# Conversion Operator Overloading

In this code snippet, we will take a look at conversion operator overloading in C#. Conversion operators can be overloaded just like regular operators. This is useful when you want to be able to convert your custom object to another type. We have two types of conversions, implicit and explicit. Implicit conversion can be “just done” no special syntax is required. Meanwhile, explicit conversion requires casting.

C# Code Snippets Reflection

C# Reflection

In this code snippet, we will take a look at reflection in C#. Reflection is used to get metadata(information) about an object at runtime. We can get members(properties, methods) of objects and their data types. Reflection is also used for late binding. The ability to see the metadata of an object is for example, useful is when you use generics, as you don’t necessarily know the data type of a generic member until the object is created.

Advertisment ad adsense adlogger