👉 Read the full lesson on DevLadder (free, lesson 1 of 12 in the VB.NET: Visual Basic .NET from Basics to Advanced (with C# Comparison) course)
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# static class; members are Shared automatically
Sub Main(args As String())
Console.WriteLine("Hello, Divakar!")
Dim name As String = If(args.Length > 0, args(0), "world")
Console.WriteLine($"Welcome {name}") ' string interpolation (VB 14)
End Sub
End Module
End Namespace
- Statements end at the line break (no semicolons); use
_for explicit line continuation, though VB 10+ allows implicit continuation after operators, commas and opening brackets. - Comments start with
'(orREM). - Blocks end with
End X(End If,End Sub,End Class). - Keywords and identifiers are case-insensitive (
dim=Dim; the IDE fixes casing).
Continue reading the lesson →
An interview question on VB.NET
What is the difference between VB.NET and C#?
Both compile to the same IL and run on the same CLR with the same libraries, so performance is the same. Differences are syntax and features: VB.NET uses English-like keywords, is case-insensitive, line-based with End blocks, has XML literals, My namespace, WithEvents/Handles and optional late binding; C# uses C-style syntax, is case-sensitive and gets new language features every year while VB.NET has been feature-stable since 2020. Most new projects use C#; VB.NET is mainly maintained in legacy systems.
Can you answer these?
- What do Option Strict, Option Explicit and Option Infer do?
- What is the difference between Sub and Function?
- ByVal vs ByRef?
- And vs AndAlso, Or vs OrElse?
The answers, plus 7 more VB.NET interview questions and a mock-interview mode, are free on DevLadder.
Next in the course: Data types, variables, constants and conversions →
Top comments (0)