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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:51:34+00:00 2026-06-17T15:51:34+00:00

So I recently had a face-palm moment with Javascript and WinRT. Basically, I’m developing

  • 0

So I recently had a face-palm moment with Javascript and WinRT. Basically, I’m developing a WinRT API, so it should work well with Javascript, C++, and C#. I have a property in the API that does special stuff if the passed in value is null. So, for instance:

public string Foo
{
  get
  {
    return foobar.ToString();
  }
  set
  {
    if(string.IsNullOrEmpty(value))
    {
      foobar=SomeSpecialValue;
      return;
    }
    ParseIntoFoobar(value);
  }
}

This seems like a perfectly fine property to me. However, when you use something like this from Javascript:

myFoobar.foo=null;

The result is a parsing exception thrown from ParseIntoFoobar Why? Because apparently the value of null in Javascript is "null" as in a string containing the word null`

From the documentation I’ve seen, this should result in either a conversion to null for C#, or it should result in an empty string, not this goofy result. In fact, you can make some really unintuitive behavior that makes no sense to me. Projection:

public string Biz{get;set;}

Javascript:

myObject.biz=null;
log(myObject.biz==null); //results in false

What is the best way to work around this “feature”? What should I do about things where I want to detect null, but where "null" as a string isn’t exactly invalid? (think username or some such)

  • 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-17T15:51:35+00:00Added an answer on June 17, 2026 at 3:51 pm

    You could just use empty string “” (string.Empty) which will be universally accepted.

    My “guess” about why null isn’t acceptable is probably because of some type mapping trickery that is happening to make everything compatible. C++ might be doing something weird like translating a null reference into a ‘\0’ (null character), which would then be an empty string.

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

Sidebar

Related Questions

I recently had to work around the different default sizes used for enumerations in
I recently had cause to work with some Visual Studio C++ projects with the
I have recently started working with C++ classes and had just started when I
I recently had to rewrite our rest api, and made the switch from Flask
I recently had a discussion with a co-worker on whether we should allow null
I recently had to implement a small check for any variables that might have
I most recently had great progress in getting Vertex buffer objects to work. So
I recently had a couple of flash products to do, which basically were a
I recently had to do some changes in some Delphi code. Therefore, I have
I recently had to perform some string replacements in .net and found myself developing

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.