dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB7, C#
Expertise: Intermediate
Aug 11, 2003

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


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.NET
Imports 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
Marco Bellinaso
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date