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 8497359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:06:15+00:00 2026-06-11T00:06:15+00:00

I need to pass values to a method, along with an indication of whether

  • 0

I need to pass values to a method, along with an indication of whether each value is specified or unspecified, since null is a valid value itself, and therefore cannot be interpreted as “unspecified”.

I took the generic approach and created a simple container for such values (see below), but is this the right way to go? Are there better ways to approach this problem – e.g. does a class like this already exist in the framework?

public struct Omissible<T>
{
  public readonly T Value;
  public readonly bool IsSpecified;
  public static readonly Omissible<T> Unspecified;

  public Omissible(T value)
  {
    this.Value = value;
    this.IsSpecified = true;
  }
}

The method signature could look like the following, allowing the caller to indicate that certain values shouldn’t be updated (unspecified), others should be set to null/another value (specified).

public void BulkUpdate(int[] itemIds, 
  Omissible<int?> value1, Omissible<string> value2) // etc.
  • 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-11T00:06:16+00:00Added an answer on June 11, 2026 at 12:06 am

    This is the best one can theoretically do. In order to distinguish a general T from a “T or null” you need one possible state more than a variable of type T can hold.

    For example, a 32 bit int can hold 2^32 states. If you want to save a null value in addition you need 2^32 + 1 possible states which does not fit into a 4 byte location.

    So you need a bool value in addition. (Theoretically speaking you just need log2(2^32 + 1) - 32 bits for the Omissible<int> case, but an easy way to store this is a bool).

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

Sidebar

Related Questions

I need to pass some values into onReceive() method in BroadcastReceiver . I'm implementing
I need to pass some values to the fseek() method in C which are
I've some scenarios where i need to pass value type as reference without changed
I have an ASP control custom built and I need to pass a value
I am trying pass class as value in hashmap. I need to get the
I need to pass a String from one method to another method and now
there is need to pass values to a lightbox in a project i am
I have to pass values from view to controller, controller having action method that
My project generates few values(equal partitioning method) for each data types by getting the
My project generates a few values (equal partitioning method) for each data type by

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.