Home >>VB.Net Programs >VB.Net program to demonstrate the duplicate case in the 'select case'
In the 'select case' here, we can identify the duplicate case without any error.
Program :
This is the source code to show the duplicate case in the 'select case.' The program given is compiled and successfully executed.
Example
Module Module1
Sub Main()
Dim choice As Char
Console.WriteLine("**************************")
Console.WriteLine(" a: India")
Console.WriteLine(" a: Australia")
Console.WriteLine(" c: USA")
Console.WriteLine(" d: UK")
Console.WriteLine("**************************")
Console.Write("Select your country: ")
choice = Char.Parse(Console.ReadLine())
Select Case choice
Case "a"
Console.WriteLine("India")
Case "a"
Console.WriteLine("Australia")
Case "c"
Console.WriteLine("USA")
Case "d"
Console.WriteLine("UK")
Case Else
Console.WriteLine("Invalid choice")
End Select
End Sub
End Module
Explanation:
We created a Module1 module in the program above that contains the Main() method. We created a variable choice for the Char class in the Main() method.
We defined the case twice in the above program, which is duplicate, but executes only one case actually established, but does not create any syntax errors.