473,404 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

C# equivalent of 'undefined'

Bob
IN JScript, we can use the keyword undefined as follows:

if (node!=undefined)
{
//do something
}

What is the equivalent of the above in C#?

Thanks,
Bob
Nov 16 '05 #1
1 2443

if (node != null)
{
// do something
}

It is the job of the developer to use a null value as meaning "undefined" or unitialized. There is no true "undefined" equivalent
in C#.

If you declare a reference type:

private string mystring;

It will be initialized as "null" within the scope of a class.

If you have a method:

private void MyMethod(string Variable)
{
}

A caller may pass a null value in as "Variable".

If you do not wish to accept null values I might suggest that you then throw an exception, depending on the context of the method:

throw new ArgumentNullException("Variable");

-- Hope this helps.

--
Dave Sexton
ds*************@somethingdigitalBYE-SPAM.com (remove BYE-SPAM)
[Please do not reply by email unless asked to]
-----------------------------------------------------------------------
"Bob" <an*******@discussions.microsoft.com> wrote in message news:21****************************@phx.gbl...
IN JScript, we can use the keyword undefined as follows:

if (node!=undefined)
{
//do something
}

What is the equivalent of the above in C#?

Thanks,
Bob

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Iain Hallam | last post by:
Hi. I've been using display:none on the style property of some <option> elements in my forms, which works fine with Mozilla - as expected it removes the option from my dropdown (although it...
3
by: effendi | last post by:
Hi Can any tell me what is the javascript equivalent of CSS border? I would like to change the border of my cell when it is set on focus. I have tried onFocus="style.border='3px'" but it is not...
11
by: Philipp Brune | last post by:
Hello Newsgroup, in c# there exists the '??' operator. It is used like this : string s1 = null; string s2 = s1 ?? "(undefined)" And does the following (simplified) :
32
by: Andrew Poulos | last post by:
I'm writing some ASP using js and I need to do a case sensitive SQL select. Googling gave me this: SELECT * FROM User WHERE Strcomp("Blue",,vbBinaryCompare)=0 Strcomp is from vbs. Is there a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.