null

How to make a value type nullable with .NET XmlSerializer?

Let's suppose I have this object: [Serializable] public class MyClass { public int Age { get; set; } public int MyClassB { get; set; } } [Serializable] public class MyClassB { public int RandomNumber { get; set; } } The XmlSerializer will serialize the object like that: <MyClass> <Age>0</age> <MyClassB> <R...

Optional function parameters: Use default arguments (NULL) or overload the function?

I have a function that processes a given vector, but may also create such a vector itself if it is not given. I see two design choices for such a case, where a function parameter is optional: Make it a pointer and make it NULL by default: void foo(int i, std::vector<int>* optional = NULL) { if(optional == NULL){ optional = new...

null used with logical operator

I have a table with name,age and address.I have totally five rows of data in the table.For some rows the age is left null.I have to display all the data where age is not null. select * from sample_table where (age !=null); But no output is displayed and it doesn't give an error also.Please explain this.Thanks. ...

Where to check if an object is null or not?

Where do you check if an object that you are passing to a method is null or not? Should an object need to be tested before calling a method? or within the method that is using the argument? public class Program { public static void Main(string[] args) { // Check if person is null here? or within PrintAge? Print...

C# DataTable ItemArray returns '{}' - how can I test for null value?

I have a DataTable resultSet; - I'm trying to check fields for null, but get an '{}' (empty-set ?) object back. Searches involving "{}" aren't yielding any appropriate solutions. This is the code that isn't working as expected when the "fk_id" field is null: if (resultSet.Rows[0].ItemArray[resultSet.Columns.IndexOf("fk_id")] == null) {...

Where to check for null, in calling method or in function?

Duplicate: http://stackoverflow.com/questions/706263/where-to-check-if-an-object-is-null-or-not should a check for null occur before making call to a function or within the function itself? ...

Vb Function returning null

is it possible for a VB.net function with a return type of integer to return null ? ...

C#: Passing null to overloaded method - which method is called?

Say I have two overloaded versions of a C# method: void Method( TypeA a ) { } void Method( TypeB b ) { } I call the method with: Method( null ); Which overload of the method is called? What can I do to ensure that a particular overload is called? ...

Oracle 10g - optimize WHERE IS NOT NULL

Hi - We have Oracle 10g and we need to query 1 table (no joins) and filter out rows where 1 of the columns is null. When we do this - WHERE OurColumn IS NOT NULL - we get a full table scan on a very large table - BAD BAD BAD. The column has an index on it but it gets ignored in this instance. Are there any solutions to this? Thanks ...

Detecting nulls in Excel VBA

In a program i'm currently working on i've created a user defined type to contain some data that i'll later use to populate my form. i'm using an array of that user defined type and as i pull more data from a offsite server i'm resizing the array. So in order to make my program easier to digest i've starting splitting it into subroutin...

How many of you are aware that its safe to delete a NULL pointer?

I just realized after years of writing C++, that I can safely delete a NULL pointer. So I figure, I'm not the only one that wasn't aware of this. Now I feel silly for all my if(p) delete p; code laying around. Am I the only one that hadn't realized this? Or is it a less known feature of C++? ...

.Net: Empty string is not clear space character?

Hi all. I've always use String.IsNullOrEmpty to check for a empty string. It recently come to my attention that a " " count as not a empty string. For example, Dim test As String = " " If String.IsNullOrEmpty(test) Then MessageBox.Show("Empty String") Else MessageBox.Show("Not Emtpy String") End If It wi...

Null object pattern in Objective-C

In Java, it is very easy to code the following design: public abstract class Pizza { public static final Pizza.NULL = new Pizza() { /* "null" implementations */ } /* actual/abstract implmentations */ } What is the preferred method to attain the same efficient scenario in Objective-C? I have been unable to find any...

How to check for an Empty Gridview

Hi, I have an ASP.NET 2.0 (C#) web app, and in it I have a gridview that gets its data from an oracle database. I want to know how to check if the gridview is empty, and the do something. I have already tried: if(GridView.Rows.Count == 0) { // Do Something } but it doesn't work... Any ideas? Thank you. ...

C#: How to pass null to a function expecting a ref?

I've got the following function: public static extern uint FILES_GetMemoryMapping( [MarshalAs(UnmanagedType.LPStr)] string pPathFile, out ushort Size, [MarshalAs(UnmanagedType.LPStr)] string MapName, out ushort PacketSize, ref Mapping oMapping, out byte PagesPerSector);...

Is there a way to require that an argument provided to a method is not null?

Is there a better way to require that an argument is not null in a method? I keep checking if any of the arguments that my method requires are null, as show below. But I'm wondering if there is a better way. public void MyMethod(string a, int b) { if(a==null){throw new ArgumentNullException("a");} if(b==null){throw new ArgumentNul...

PL/SQL: Procedure not working correctly in a package

I'm working on a package with some procedures in them and I'm running into a bit of trouble. When I try to test the procedure to convert gallons to liters or the other procedures, it just prints out what was declared in the unnamed block instead of converting the numbers. Any ideas? CREATE OR REPLACE PACKAGE eng_metric IS PROCEDURE ...

A nicer way to handle null references in a object hierarcy

I’m looking for a nice way to handle a null reference in object hierarchy. ie: if(null == Object1.Object2.Object3.Property) This example will throw a Null Reference exception if say Object2 is null. In my case I don't care what is null, just that something is. I don't really want to put try/catches around each place that I want to d...

Access Query Error - Null & Variant Data Types - How do I fix this error?

All, This error is driving me insane. I've spent 2 hours trying to figure it out and/or work around it with no luck. Here's the error: "You tried to assign the NULL value to a variable that is not a Variant data type." Here's my SQL: SELECT tbl_budir_002.Location_Index, tbl_parent_001.NEWPARENTID INTO tbl_budir_003 FROM (tbl_budi...

how to check if a datareader is null or empty

I have a datareader that return a lsit of records from a sql server database. I have a field in the database called "Additional". This field is 50% of the time empty or null. I am trying to write code that checks if this field isnull. The logic behind this is: If the field "Additional" contains text then display the info otherwise hide...