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.

C# Code Snippets Operator Overloading

C# Operator Overloading

In this code snippet, we will take a look at operator overloading in C#. Just like methods operators can be overloaded too. In the code below we have an example with geometric shapes. If we use the + operator on two objects of GeomentricShapes we get an error. This happens because the compiler doesn’t know what is supposed to happen when the  + operator is used on a GeomentricShapes object. We have to overload the + operator and write the code to be executed when two GeomentricShapes objects are added together. 

C# Code Snippets Attributes

C# Attributes

In this code snippet, we will take a look at attributes in C#. Attributes are used to add additional information(metadata) to code. For example, you can use [Serializable] to indicate that a class can be serialized. Or as I will demonstrate in the code example a method can be marked as obsolete and Visual Studio will warn you when you attempt to use the obsolete method. 

MAX II CPLD USB Blaster Connection

MAX II CPLD Basic Getting Started Tutorial

This tutorial will cover the hardware and software setup for the MAX II CPLD. We will also make a simple design to upload to the CPLD. This little dev board can be picked up on eBay or Aliexpress for around 10 bucks(including the USB blaster). It’s cheap, easy and simple compared to some of the other FPGA dev boards. Despite that, I didn’t find a lot of tutorials and projects(compared to the Arduino stuff) with this board so I thought I’d make a tutorial.

Advertisment ad adsense adlogger