Skip to main content
1 vote
2 answers
147 views

In some languages, we can declare and initialize an anonymous struct - or the equivalent thereof - seamlessly. Example from ECMAScript: function foo_in_ecmascript(x) { let computed = { ...
einpoklum's user avatar
  • 137k
0 votes
3 answers
90 views

Let's assume we have a class defined as: class A { public int Param { get; set; } public Action DoSomething { get; set; } } The DoSomething action is assigned in another class, but it needs ...
Jake's user avatar
  • 121
5 votes
3 answers
205 views

Often I need a read-only ObservableCollection (so that it's reference or contents can be only modified from within this class). I need ObservableCollection because I will be binding to that property ...
Justin8051's user avatar
0 votes
2 answers
60 views

Given the following sample POCO class: public class TestClass { public int Id { get; init; } public TestClass() {} } How can I initialize the Id property using Reflection? The result should ...
AxD's user avatar
  • 3,262
1 vote
1 answer
112 views

I am using Groovy to create a package that I use in ReadyApi. In a Groovy script test step, I do the following: class B { String value boolean isSomething } class A { String name B ...
Aymen Turki's user avatar
2 votes
1 answer
64 views

The following C++ code compiles with no errors or warnings, but for some reason when I print out the contents of foo.arr I just get junk values. It looks like the array member is not being properly ...
user4574's user avatar
  • 416
0 votes
1 answer
160 views

Is there a way to pass default/constructed property vales in object initializers - to the constructors of nested object initializers? e.g. take these 3 classes Car, Part, Tool Car { public Guid ...
Joseph Hutton's user avatar
0 votes
2 answers
791 views

Let's assume I've the following C# class: public class Test { public double X; public double Y; } I want to use the above C# Test class from IronPython and as well from CPython (using ...
Wollmich's user avatar
  • 1,684
3 votes
2 answers
874 views

While searching around for how to work with HTTP request headers, i've seen a ton of examples use this construct to initialize the HttpRequestMessage: var request = new HttpRequestMessage() { ...
Mario Š.'s user avatar
0 votes
1 answer
414 views

I'm trying to initialize properties of an object I am creating with the values of a named tuple. Something like this public Person DoIt() { return new Person { (First, Last) = GetFirstAndLast(id)...
comecme's user avatar
  • 6,446
0 votes
2 answers
155 views

This is stripped down from a more complex situation. The goal is to construct several instances of class SubAction, each of which uses an action to alter how it uses its internal data. Consider: ...
ToolmakerSteve's user avatar
0 votes
0 answers
302 views

Is there a way to initialize a C++ struct/class with very large array members? I would like to initialize them by filling them with any kind of data besides an empty array. The following code is ...
karobar's user avatar
  • 1,360
0 votes
2 answers
3k views

I am trying to implement object initializer. All the classes are already created by someone else. I cannot change. I have a class Ins.vb that has a list as a property Partial Public Class Ins ...
that_noob's user avatar
  • 123
1 vote
1 answer
196 views

While playing around with a simple Javascript Object Initializer example, I could not find an explanation while the following code: const obj = { self: this }; console.log(obj); would ...
tmarwen's user avatar
  • 16.5k
0 votes
0 answers
98 views

I have the following code: class Foo { public: enum class MyEnum { option1, option2 } "Some constructors" private: "Some members and the following member" ...
A. Cimet's user avatar

15 30 50 per page
1
2 3 4 5
16