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

All Questions

Tagged with
0 votes
1 answer
224 views

Loop through objects properties in an object

I have got an object like below public class MainObj { public int BankDetailPercentage { get; set; } public int PersonalDetailPercentage { get; set; } public BankDetail BankDetail { get; ...
Luke's user avatar
  • 3
1 vote
2 answers
577 views

C# with object types the method Object.Equals (object a, object b) returns the wrong result [duplicate]

I need to check the object (not all properties), with primitive types everything works correctly, but with object types the method Object.Equals(object a, object b) returns the wrong result. ...
Espi4U's user avatar
  • 17
1 vote
2 answers
86 views

how to get varriable name over another one c#?

string MyVar1 = "bilah bilah"; dosometing(MyVar1); void dosometing(object MyObject) { string VarName = nameof(MyObject); // it givess : "MyObject" } But I ...
Ali CAKIL's user avatar
  • 418
2 votes
1 answer
624 views

How to create a delegate for a property setter with its type as object

I'm looking for a way to creating a delegate for the setter of a property without knowing the property type, say, instead of having Action<TClass, TType>, I would like Action<TClass, object&...
Vincent Minotto's user avatar
0 votes
0 answers
201 views

Compare two Complex Objects in c#

I am trying to compare two objects and want to identify the difference in objects. It works fine if I don't use List. But when I use List, Although the List in both objects are equal, it says it's ...
Mustafa Gaziani's user avatar
-1 votes
1 answer
227 views

C# Object Property to Load Values from List

I have a class with a property: public object something { get; set; } I obtain a list of values from a method, say List<string> myList and I would like to load each value into property ...
Nick's user avatar
  • 513
1 vote
3 answers
222 views

Create object by merging other three with priority (C# .NET 3.5)

I have three C# (using .NET 3.5 for a legacy sw) objects of the same class (A, B, C) that has all public properties (string, int, short, byte, datetime, double) I need to create a fourth (D) by ...
Danilo7's user avatar
  • 47
0 votes
1 answer
160 views

How to get List<int> from System.Object retrieved by reflection?

As suggested by @John, here is re-write: Consider this code: public object Foo(object original) { List<object> origList = original as List<object>; //problematic line, origList is ...
sanitizedUser's user avatar
-1 votes
2 answers
53 views

Iterate through value of an object [duplicate]

I have and object say Object abc = new List<myclass>(); currently abc is of Type Object and pocess 1000 records say. What my need is to iterate through these values. Is there a way to do this?
Anish Karunakaran's user avatar
1 vote
1 answer
590 views

How to set property value of object inside function?

I am using entity framework along with a repository pattern to interact with the database. For simplicity I am doing something like this. public T Update(T entity) { // Update Entity } What I ...
Demodave's user avatar
  • 6,522
0 votes
0 answers
35 views

Reflection: Read List-type properties of an object, containing another object

I am trying to serialize nested objects using reflection. I am able to do this fine for properties containing a single value, but I am having trouble with list type properties that contain another ...
yulivee's user avatar
  • 327
0 votes
2 answers
167 views

Instantiate the parent class in a child class method

public class Parent {} public class Child: Parent { public Child() { Parent instance_of_Parent = INSERTCODEHERE; } } How can I create the desired instance of the parent class in a ...
Sparr's user avatar
  • 7,636
-2 votes
2 answers
699 views

c# reflection comparing 2 objects with boolean properties

I have two objects with several properties that are of type boolean. The properties are identical in terms of naming and I just want to make sure they are equal. I do a lot of these checks and want to ...
dylandotnet's user avatar
0 votes
1 answer
5k views

In C#, Generically get the property value within a List object

I have a Match object structured as, class Match { public string location { get; set; } public List<Team> teams { get; set; } public Match() { location = "Wembley"; ...
user avatar
0 votes
0 answers
35 views

How can i get all sub classes in a class using reflection in C# [duplicate]

how to get all sub classes under main class I want to get class structure using Reflection and show that in a TreeView. that is what i did but it's dosen't works!! Here is just a Test class to ...
M.Koudarzi's user avatar

15 30 50 per page
1
2 3 4 5 6