Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
2 votes
2 answers
279 views

Getting all values of properties of an object into an array in c#

Im trying to get all the field values of an object into an array. but the problem is the fields of the object can have other types rather than string but ultimately all the values should be a string. ...
DBankx's user avatar
  • 21
0 votes
3 answers
48 views

C# object list that can be declared, returning an iteration of items to be inserted into the main list

C# question. I need to fill my main object property, that is a list of a custom object, but at some point, I need to add to this list a replication with a specific declaration, but I don't want to ...
Luis Pedro's user avatar
1 vote
3 answers
70 views

Unable to cast to object

I had a code: var result = BOBase.Search(Mapper.SourceBrowserType, searchCriteria); var list = new List<IBO>(result.OfType<IBO>()); But I need to be able to add many elements in a list. I ...
vytaute's user avatar
  • 1,440
0 votes
0 answers
333 views

how to pass object to test method in nunit in c#

How can I pass an object while testing with NUnit in c# Hi I have written some code and am trying to use NUnit Test. When I pass int or string it works but I dont know how to use this test method with ...
Amir's user avatar
  • 1
-2 votes
2 answers
103 views

Want to access dynamic property name from dynamic object

I have following JSON format. { "data": [ { "id": 1, "variants": [ { "name": "Test", ...
Sami In's user avatar
  • 330
1 vote
1 answer
67 views

C# maintaining HasChanged for class of list properties

I am converting my code from datasets to list of class objects. For checking if any value in list is of object is modified or added or deleted, I am using object tracking technique. My code is as ...
Abhishek Singh's user avatar
1 vote
1 answer
98 views

Creating child classes that only inherit parents data once

Currently I'm trying to create some attribute let's call it "DoNotShareWithGrandChildren" that will be used by the highest level parent class but not the children classes below it. The issue ...
Caleb Laws's user avatar
0 votes
2 answers
515 views

Convert List<object> to List<model> type with only the model name c# mvc

So I'm trying to create a generic function (currently it's not but I wanted to future proof it, so in a later stage the tableName can be picked/passed through). I want to use the string ...
Manib's user avatar
  • 181
-1 votes
1 answer
98 views

C# Json.NET hide objects (not properties) when serializing

I want to hide objects (not properties) when serializing with Json.Net. The situation is: In a list of images, there are many images, including attributes such as Class, Name, and Layers. Within the ...
Ricky Chen's user avatar
1 vote
0 answers
105 views

How to cast object to Anonymous T

I'm having a problem casting with C# First, my auxiliary functions for better understanding public static class Extensions { public static IEnumerable<T> ToEnumerable<T>(this T value) {...
Uğur Demirel's user avatar
0 votes
0 answers
82 views

Problem with dynamic variable in C# | MongoDB

I am writing this post today because I am currently stuck on a part of MongoDB I want to upload a custom class, in a dynamic variable, but when I create a document on Mongo, the dynamic variable is ...
HugoTek's user avatar
  • 43
0 votes
2 answers
1k views

Add new property to existing object - c#

When both 'if' condition is satisfied, I want Start to be added to the same DataList along with value and time. public List<object> DataList = new List<object>(); if(somecondition) { ...
st27's user avatar
  • 9
-1 votes
2 answers
52 views

How to output the values of List<int> from an object. (Not list of objects) C#

I am inputting information from a json file and then need to check that the information is correct. I am not sure how to print out the values of a List from an object. Not all objects have the same ...
new_to_coding's user avatar
-3 votes
2 answers
167 views

System.NullReferenceException Object reference not set to an instance of an object (List) [duplicate]

public List<Faculty> Faculties {get;set;} List<Faculty> faculties = FacultiesManager.Faculties; Faculties.Add(something); how can i interact with the object list
nomnom's user avatar
  • 17
0 votes
0 answers
113 views

Can I create a C# object containing a form's controls and their properties?

I'm currently working on a Windows Forms application in C#. At the moment, I have four forms that have multiple controls of a variety of different types (textboxes, datagrids, labels etc) and I ...
Ian Henderson's user avatar

15 30 50 per page