VB.NET Syntax Tips

Difference Between C# and VB.NET Namespace

VB.NET

  • [Class Namespace in IL]=[Root Namespace].[Namespace in File]
  • Class is not automatically added namespace, root namespace is added in background.
  • Root namespace is setted at Application Tab of Project Properties.

C#

  • [Class Namespace in IL]=[Namespace in File]
  • Class is automatically added root namespace.
  • Root namespace is setted at Application Tab of Project Properties.

Options

Option Strict On
Option Explicit On

Erase Statement

Used to release array variables and deallocate the The Erase statement dates from old versions of Basic, the kind where manual memory management was useful.

No more, memory management is automatic in .NET. It is still supported for compatibility reasons.

All it does is set the array reference to Nothing. memory used for their elements.

Erase arraylist

Set Variable Name as Keyword

  • use square brackets
private [Date] as string

Get Base Class Private Field

correct: Me.GetType().BaseType().GetField("fieldName", BindingFlags.NonPublic Or BindingFlags.Instance)

uncorrect: MyBase.GetType().GetField("fieldName", BindingFlags.NonPublic Or BindingFlags.Instance)

原文地址:https://www.cnblogs.com/dalianliyan/p/5391811.html