C# Constants
In this tutorial, we will learn about constants in C#. A constant is a variable that is marked with the const keyword. Such a variable can only have its value set once at compile-time, after that it canāt be changed anymore.
In this tutorial, we will learn about constants in C#. A constant is a variable that is marked with the const keyword. Such a variable can only have its value set once at compile-time, after that it canāt be changed anymore.
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.
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.
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.Ā
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.Ā
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.
In thisĀ code snippet, we will take a look at data typesĀ in C#. Preprocessor directives are statements that get executed before compilation. They are designated by the # sign. Preprocessor directives can, for example, be useful when debugging code. Suppose we can make an if statement that checks whether the program is in debug mode. If so we would enable some diagnostic output otherwise we wouldn’t.
In thisĀ code snippet, we will take a look at GUIDs in C#. A GUID or a Globally Unique Identifier(also known as a Universally unique identifier )Ā is an alphanumeric sequence of character that make up a completely unique identifier(at least in theory). One place a GUID can be used is with databases to serve as a unique ID.
In this code snippet, we learn how to chain constructors in C#. Constructors are methods meaning you can overload them. Overloading can lead to code duplication. We can use chaining to get rid of the code duplication. Instead of implementing duplicate code in the overloaded method we can just call the previous method. This process is called chaining.
In this code snippet, we will learn how to overload methods in C#. MethodĀ overloading is when you make more than oneĀ methodĀ with the same name. The other method/methods must, however, have a different signature(different input parameters) so the compiler can differentiate between the versions.Ā