Current responses do not exactly simulate what happens with JS. It may even achieve a similar (and not the same) result, but in a very different way. So it correctly simulates:
using static System.Console;
using System.Dynamic;
public class Program {
public static void Main() {
dynamic obj = new ExpandoObject();
obj.propriedade1 = "valor1";
obj.propriedade2 = "valor2";
WriteLine(obj.propriedade1);
WriteLine(obj.propriedade2);
}
}
See working on dotNetFiddle .
ExpandoObject()
documentation .
In this way you can add and remove members in the object as you can in JS. You can manipulate everything dynamically as it is in JS, with a standard language syntax. So the object is created without having a class as a template, but it behaves as if it were a normal .Net object.
It may not be necessary for the AP, but the premise of the question indicates this.