0

I use this to create a dynamic object in Visual Basic before sending it as an JSON

Dim my_object = New With { _
   .Name = String.Empry, _
   .Telephone = String.Empry, _
   .ID = String.Empry
}

How can this be done in C#?

1
  • 5
    This is not a dynamic object, this is an anonymous type. Commented Feb 5, 2013 at 20:56

2 Answers 2

12

That is an anonymous Type.

var my_object = new
{
    Name = string.Empty,
    Telephone = string.Empty,
    ID = string.Empty
};

However, note that Stackoverflow is not a translation service normally.

Use this site instead: http://www.developerfusion.com/tools/convert/vb-to-csharp/

Sign up to request clarification or add additional context in comments.

Comments

9

If you mean creating an instance of an anonymous type:

var my_object = new {
    Name = string.Empty,
    Telephone = string.Empty,
    ID = string.Empty
};

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.