Program structure, modules and the Main method — VB.NET
Lesson 1 of 12 in the free VB.NET — Visual Basic .NET from Basics to Advanced (with C# Comparison) course on DevLadder. Option Strict On ' no implicit narrowing conversions or late binding — always turn on Option Explicit On ' every variable must be declared Option Infer On ' allow Dim x = 5 (type inferred) Imports System.Text ' = C# using Namespace Divakar.Shop Module Program ' a Module = C#…
The lesson on VB.NET structures covers the importance of Program modules and the Main method. Option Strict On ensures that implicit narrowing conversions and late binding are strictly avoided. To enforce this, Option Explicit On should be enabled to require variable declarations. Option Infer On enables the compiler to infer variable types, as seen in Dim x = 5.
Imports System.Text is equivalent to C#'s using directive, while Module Program mirrors the static class concept from C#. The Sub Main with String() parameters is the entry point for the program, akin to the Main method in C#.
Within the Main method, the program prints "Hello, Divakar!" using Console.WriteLine, and then employs string interpolation to display "Welcome world" or "Welcome Divakar!" depending on user input. A direct quote from the lesson is: "string interpolation (VB 14)".
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.