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

  • SEARCH
  • Home
  • 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 7733285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:56:58+00:00 2026-06-01T06:56:58+00:00

I need to check if an object contains any value. The following function works

  • 0

I need to check if an object contains any value. The following function works fine if the object is a String type but I was looking to replace this with a generic way without checking for the type. Is there a way to do this? Thanks in advance.

 public void SetValue(int id, object fieldData)
    {
        if (fieldData!=null)
        {
            if (fieldData.GetType() == typeof(String) && fieldData.Equals(string.Empty))
            {
                return;
            }
        }

        SetLOValue(id, fieldData);
    }
  • 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-06-01T06:57:00+00:00Added an answer on June 1, 2026 at 6:57 am

    You can check for default types if you make it generic, but you have to be sure that’s what you want. i.e. is 0 a valid number in your usage?

    if (fieldData == default(T))
    {
      return;
    }
    

    Alternatively, you could switch to Nullable types.

    if (fieldData.HasValue)...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a simple way to check the type of an object? I need
I have an object parameter and I need to check if the object implements
Imagine this case where I have an object that I need to check a
As I iterate through a DataTable object, I need to check each of its
I need to convert an integral type which contains an address to the actual
I have a list of urls, I need to check which of the following
Ok I have a big JS object that contains data I need within 3
i have an array list of custom objects. each object contains a value i
I have a value that is either of a boxed (any) numeric type, or
I am using below code to check ary_navigationControllerViews array contains myclass object or not

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.