Questions tagged [anonymous-objects]
56 questions
2
votes
1 answer
How to serialize anonymous object to JSON without including property name
I have the following code:
///
///In this case you can set any other valid attribute for the editable element.
///For example, if the element is edittype:'text', we can set size, maxlength,
///etc. attributes. Refer to the valid attributes…

juliano.net
- 7,982
- 13
- 70
- 164
2
votes
4 answers
Finding an item in a list of anonymous objects in C#
I have a list of anonymous objects as:
var jobs = new List

MaYaN
- 6,683
- 12
- 57
- 109
2
votes
2 answers
Why can't I instantiate a generic class inferring types from anonymous objects?
Let's say I have some class - hypothetical example:
public class InvalidResponseException : Exception
{
public TReq RequestData { get; protected set; }
public TResp ResponseData { get; protected set; }
public…

BenAlabaster
- 39,070
- 21
- 110
- 151
1
vote
1 answer
Read model properties where model is passed as an Anonymous object - C#
I am working with a method that takes an anonymous object and a string, and then compares the string to the object property names.
In this example the object is a model that contains basic properties and a custom class property:
Model:
class…

Rumpo
- 41
- 1
- 4
1
vote
1 answer
Is operator lookup different for temporary/anonymous objects?
I am trying to understand why named and temporary (anonymous?) objects seem to behave differently when looking up an operator defined in a base class. In the following code I've made a wrapper around a variable of 'mytype' which I want to switch…

Tom_DB
- 11
- 1
1
vote
0 answers
Is it valid to declare a variable without a name
I came across the following comment:
What is unsigned;
By looking at the declaration above I thought it is invalid. So to empirically verify this i tried the same with different compiler and to my surprise it works in some and rejected in…

Jason
- 36,170
- 5
- 26
- 60
1
vote
1 answer
Typing the properties of an anonymous object in TypeScript
I've got a function:
function someFunction({ propertyA, propertyB })
{
return 1;
}
I want to give the properties in the anonymous object in the argument to the function an explicit type, but using the typical TypeScript syntax for this…

Mick McCarthy
- 428
- 2
- 16
1
vote
2 answers
LINQ to XML: creating complex anonymous type
I've an xml file as follows:
Roses
Floral
46
img1.jpg
img2.jpg
…

deostroll
- 11,661
- 21
- 90
- 161
1
vote
2 answers
What is the Java UML Sequence order when passing an anonymous object as parameter?
Sorry if title phrasing is bad, feel free to edit if need be.
Let's assume a Main Class, that creates an object from the class A, whose constructor receives an object from the class B as a parameter. One way to code it is :
B b = new B(); A a = new…

Gael L
- 243
- 1
- 11
1
vote
1 answer
Creation of anonymous userdata variables
I'm working with the lua C api to run scripts that interface with native clases. I'm taking advantage of Qt's MOC for the run time type information. So far, I've implemented the creation, deletion, and indexing of all the classes I want lua to be…

mrg95
- 2,371
- 11
- 46
- 89
1
vote
2 answers
Anonymous object Creation and GC
How are anonymous objects, like used in case of return statements for example :
return new JsonObject().put("name","xyz")
are allocated in the Heap ? As they don't have any named references, how does the Garbage Collector clear them from the memory…

DebashisDeb
- 392
- 5
- 13
1
vote
0 answers
Why doesn't this compile? anonymous class + anonymous object c++17
Question: Why aren't anonymous object of anonymous classes allowed by visual c++17?
Anonymous objects are allowed (I think it's just a temporary in this case?):
class Foo
{
public:
virtual int bar() = 0;
};
int main()
{
class ConcreteFoo :…

Jupiter
- 1,421
- 2
- 12
- 31
1
vote
3 answers
How to correctly parse Dictionary into
I was working on HtmlHelper.AnonymousObjectToHtmlAttributes.
It works well with anonymous object:
var test = new {@class = "aaa", placeholder = "bbb"};
var parseTest= HtmlHelper.AnonymousObjectToHtmlAttributes(test);
The result parseTest has two…

Blaise
- 21,314
- 28
- 108
- 169
1
vote
0 answers
Convert specific xml elements to datatable C#
I have a powershell script that converts specific xml elements into a CSV. I would like to extend the functionality utilizing C#. the powershell script is as follows:
{
[xml]$inp = get-content $infile
…

user5019819
- 63
- 1
- 1
- 11
1
vote
2 answers
Is there a way to be sure that a const reference stored in class will always refer to a valid object?
I have written the following sample code:
#include
class B
{
int Value;
public:
B(int V) : Value(V) {}
int GetValue(void) const { return Value;}
};
class A
{
const B& b;
public:
A(const B &ObjectB) : b(ObjectB) {}
…

Irr
- 656
- 1
- 9
- 19