Variable Scope: Function : Variable Scope « Language Basics « VB.Net






Variable Scope: Function

Imports System
Imports System.Diagnostics

Public Class MainClass

    Shared Sub Main()
        For i As Integer = 1 To 5
            Dim j As Integer = 3
            If i = j Then
                Dim M As Integer = i + j
                Console.WriteLine("M: " & M)
            Else
                Dim N As Integer = i * j
                Console.WriteLine("N: " & N)
            End If

            Dim k As Integer = 123
            Console.WriteLine("k: " & k)
        Next i
    End Sub
End Class


           
       








Related examples in the same category

1.Block scope variable XBlock scope variable X
2.Variable Scope DemoVariable Scope Demo