• Saves Valuable Time
  • Trusted Accuracy for 12 Years
  • 15-Day Money-Back Guarantee

C# Equivalent to VB Object Initializers

Named Type Object Initializer

VB.NET C#
Dim myVar = New Person() With
{
    .Name = s1,
    .Surname = s2
}
var myVar = new Person()
{
    Name = s1,
    Surname = s2
};

Anonymous Type Object Initializer

VB.NET C#
Dim myVar = New With
{
   .Name = x,
   .Surname = y
}
var myVar = new
{
   Name = x,
   Surname = y
};


Use Instant C# to convert from VB.NET to C#.     

Additional resource: VB.NET and C# Equivalents


Copyright © 1997 – 2017 Tangible Software Solutions Inc.