How to use alias for the common use constant in .NET
Posted by Admin L in .NET Programming on 19-11-2012. Tags: .NET Programming Experience, .NET FAQ, .NET Skills, .NET Q & A, VB .NET Programming Experience, VB .NET Q & A, VB .NET FAQ, VB .NET Skills
Author: Nosa Lee
Original Address: https://www.seeksunslowly.com/dot-net-use-alias-common-constant
To reprint this article, please indicate the source, thank you.
_____________________________________
For example in VB .NET:
Such as we need to write the string like MsgBoxStyle.Information every time, if you feel it is too long, you can use an alias to replace it (in fact it will not be slow for writing, just occupies the code space).
Usage:
Imports MBS = Microsoft.VisualBasic.MsgBoxStyle
And then you can use MBS.Information to replace MsgBoxStyle.Information in this module.
Usually, we may need to enjoy this short alias in whole project, how to do?
It is very easy, just import it at the References property page of the project.
Please see the following screenshot to know it clear: