Questions tagged [anonymous-objects]

56 questions
0
votes
1 answer

Is it possible to create anonymous object with child as object as well in C#?

I want to create anonymous object in C#, and some its child is also object. Is it possible to do that in C#? (PS. I got some hint error for the following code) var o = new { age = 123, child = { name = "asdffff"} };
Xin
  • 33,823
  • 14
  • 84
  • 85
0
votes
1 answer

Is it possible to print the returned value of a function of different class in case of Anonymous object of scala

I am new to Scala, trying to understand the syntactic behaviors of Scala. I will be really appreciated if anybody help me. Thanks With Anonymous Object: Here in this scenario if I want to print the value of resinside the main function body then what…
Alto
  • 86
  • 9
0
votes
2 answers

How to group and merge/flatten a list of anonymous objects in LINQ

I have a list of anonymous objects generated by a LINQ query that I do not have access to modify. The objects have the following properties: OrderId, RepId, FirstName, LastName, Address Each "Rep" often places multiple orders, so there are a lot of…
Stu Ratcliffe
  • 269
  • 3
  • 14
0
votes
0 answers

How the array is actually converted into an object and what's the purpose/benefit/necessity of doing it?

I've a following already pre-written program in PHP which converts an array into object : 'foo'); var_dump(isset($obj->{'1'})); // outputs 'bool(false)' var_dump(key($obj)); // outputs 'int(1)' ?> With the…
PHPLover
  • 1
  • 51
  • 158
  • 311
0
votes
1 answer

Is it possible to load a UserControl into an anonymous object, instead of just instantiating it?

Currently I'm generating UserControls as follows in an abstract base class so they are available for any other pages that implement the base class: // doc is an XML file that may or may not contain a TopStrapline node var pageControls = new { …
DaveDev
  • 41,155
  • 72
  • 223
  • 385
0
votes
0 answers

WCF sending object through pipe communication

I got a big issue trying to make this work. I have a WCF scenario, with callbacks, trying to send a Message that is a struct made of a string and an object. Seems like the object can't be serialized. I get the following error trying to call a…
AAlferez
  • 1,480
  • 1
  • 22
  • 48
-1
votes
3 answers

c#.net create a simple anonymous object and convert it to class type

maybe I'm not clever enough, but... I have a freshly created anonymous object and wanna cast it to a special class. I tried something like: () convert: SomeClass casted = (ClassName) obj as type: SomeClass casted = obj as ClassName The last idea…
Froschkoenig84
  • 566
  • 4
  • 13
-1
votes
1 answer

How can we create an anonymous object from json string in c#?

My JSON string will be like when I deserialize it using Newtonsoft.Json, instead of object I am getting below response But it should be like below image tried JsonConvert.DeserializeObject and JObject.Parse. is there any way to get in direct…
Vijay
  • 17
  • 1
  • 5
-2
votes
1 answer

C# anonymous object property inside a generic method after casting

CS1061 'object' does not contain a definition for 'Id' public static async Task RemoveItem(object obj) where T : class, new() { if (obj == null || db == null) return; obj = obj as T; await db.DeleteAsync(obj.Id); //…
user3772108
  • 854
  • 2
  • 14
  • 32
-2
votes
1 answer

c++, Create Anonymous SubClass Object in Abstract Class

I have an Abstract Class and I need to create two anonymous subclasses objects for it. I have multiple subclasses. Just write the code to create one of these objects
-2
votes
1 answer

How can I access the properties of an anonymous object?

$.post("test.php", { name: "John", time: "2pm" }, function(data){ alert("Data Loaded: " + data); }); The object { name: "John", time: "2pm" } is anonymous. Normally, I would access the properties of an object using syntax similar to the…
Delirium tremens
  • 4,623
  • 9
  • 46
  • 59
1 2 3
4