Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

218
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda