Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
What is VB.NET equivalent of this way to create instance?

In C# you can create an instance like this:

Custom mycustomelement = new Custom { ElenentName = "My Custom Element" };

I wonder how I can create instance like this in Visual Basic and what this type of creating instance is called.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It's called an object initializer, and the corresponding VB.NET syntax is:

Dim mycustomelement As New Custom With { .ElementName = "My Custom Element" }

(Note the dot (.) before the property name, which matches the syntax of VB's With statement.)


Note that there is a subtle difference between C# and VB when using the object initializer syntax for anonymous types: In C#, all properties are immutable; in VB, they are mutable unless they are initialized with the Key keyword.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!