Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7174569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:05:01+00:00 2026-05-28T16:05:01+00:00

I have userObject which has about 30 properties. I get a updated userObject from

  • 0

I have userObject which has about 30 properties.

I get a updated userObject from the server and only sets the properties of the ones that have changed and returns the rest as null.

i am currently using a foreach and chk the value from the server is not null then update it. Is there a way to just to update the cells that are not null using linq?

linq to object

public class UserProfile
   {
        public string string00 { get; set; }
        public string string01 { get; set; }
        public string string02 { get; set; }
        public string string03 { get; set; }
        public string string04 { get; set; }

        public boolean bool00 { get; set; }
        public boolean bool01 { get; set; }
        public boolean bool02 { get; set; }
        public boolean bool03 { get; set; }
        public boolean bool04 { get; set; }
   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:05:02+00:00Added an answer on May 28, 2026 at 4:05 pm

    You can use Reflection.

    class Program
    {
        static void Main(string[] args)
        {
            myClass currentObj = new myClass() { Text = "test", Value = 5 };
            myClass updatedObj = new myClass() { Text = "test 2 ", Value = 6 };
            Type cType = currentObj.GetType();
            var fieldInfos = cType.GetFields();
    
            foreach (var fieldInfo in fieldInfos)
            {
                if (fieldInfo.GetValue(updatedObj) != null)
                {
                    fieldInfo.SetValue(currentObj, fieldInfo.GetValue(updatedObj));
                }
            }
        }
    }
    
    class myClass
    {
        public string Text;
        public int Value;
    }
    

    Just Template the code and change it into a function.
    Some more info: here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class (USER) which has the following properties (NSString name, NSString address,
I have a function that loads a user object from a web service asynchronously.
I have a model which has a collection of users. I'm looping through this
I have a User object which has a collection of Transaction objects under it.
I have a user object represented in JPA which has specific sub-types. Eg, think
We have a server application that exposes a certain model, and set of services
I have a controller which inherits from an abstract secure controller which holds a
I have a User table which has a foreign key to the UserType table.
I have a windows service that references an assembly which contains the following class.
I have a User table that has serialized data in one of the tables.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.