VB.net Program to Create an Alias of a Namespace

You are currently viewing VB.net Program to Create an Alias of a Namespace

VB.Net program to create an alias of a namespace

'VB.net program to create an alias of a namespace.

Imports MyAlias = ConsoleApplication1.MathNamespace.Nested

Namespace MathNamespace
    Class AritheMatic
        Sub Add(ByVal num1 As Integer, ByVal num2 As Integer)
            Console.WriteLine("Addition is: {0}", num1 + num2)
        End Sub

        Sub Subtract(ByVal num1 As Integer, ByVal num2 As Integer)
            Console.WriteLine("Subtraction is: {0}", num1 - num2)
        End Sub
    End Class

    Namespace Nested
        Class Fact
            Sub CalculateFactorial(ByVal num As Integer)
                Dim fact As Integer = 1

                For i = num To 1 Step -1
                    fact = fact * i
                Next
                Console.WriteLine("Factorial is: {0}", fact)
            End Sub
        End Class

    End Namespace
End Namespace

Module Module1

    Sub Main()
        Dim airth As New MathNamespace.AritheMatic
        Dim fact As New MyAlias.Fact

        airth.Add(5, 8)
        airth.Subtract(40, 15)

        fact.CalculateFactorial(4)
    End Sub
    
End Module
Addition is: 13
Subtraction is: 25
Factorial is: 24
Press any key to continue . . .

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply