Using aliases to quickly change the type of variables

Using aliases to quickly change the type of variables

It may happen that you have to define a lot of variable of some type, and you want the possibility to later change their type without manually change the declaration of all of them. You can’t use a simple Find & Replace, because you don’t want to change the type of ALL the variables of that original type. The solution is to create an alias for a type, and use it in the variable declarations. When you later want to change the type of the variables, you just change the type that has that alias. Here’s how you declare an alias:

' define the alias in VB.NETImports DefaultType = System.Double' // define the alias in C#using DefaultType = System.Double;

From now on, just declare the variables using the alias instead of the real type name:

Dim var As DefaultType = 1.2

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular