Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Using aliases to quickly change the type of variables

Total Hit ( 3232)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


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:

Click here to copy the following block
' 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:

Click here to copy the following block
Dim var As DefaultType = 1.2


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.