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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:27:41+00:00 2026-06-10T19:27:41+00:00

Normally you cannot usr an ObjectId as an optional argument in C# due to

  • 0

Normally you cannot usr an ObjectId as an optional argument in C# due to the fact that ObjectId is a struct with no “Design time constant” default value.

ObjectId.Empty is a property that executes code and default(ObjectId) is not allowed for the same reason.

Does anyone have a solution on how to create a working design time constant so that the following statement would work? (This is not the real method but an example)

MyObject LoadOrCreate(ObjectId id = somedefaultvalue)
{}

If I try this with any ov the above examples it will not compile?

I can of cause use a separate overload of the method but I rather use optionals than overload.

As I noted in my comment to the first answer, nullable is an option but one I prefer to not use due to having to cast back to not nullable.

So I am still looking for some “better” solution 😉

  • 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-10T19:27:42+00:00Added an answer on June 10, 2026 at 7:27 pm

    Make it Nullable and default to null?

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

Sidebar

Related Questions

I discovered today in iReport that I cannot set the initial value expression of
Normally (ie. not concurrently), putAll() cannot be more efficient than using lot's of calls
Normally I would refrain from asking vague questions but in this case I cannot
From Herb Sutter's GotW #6 Return-by-value should normally be const for non-builtin return types.
After adding plone.app.async, I cannot start my production instances normally using 'bin/instance start'. However,
The author of this article states that Normally you don't want to have access
I'm interested in making an immutable class that has properties that cannot be modified,
/usr/lib64/gcc/x86_64-suse-linux/4.5/../../../../x86_64-suse-linux/bin/ld: cannot find -lrtdk I can't find anything regarding this in the ld's manpage.
Normally I have: cookies[:location] = { :value => { :city => 'foo', :country =>
My understanding is that Google Analytics (the tool I'd normally use for website analytics)

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.