1
голосов
1ответов
138 просмотров

De-referencing null in VS with Windows 7

I have noticed that when I was running Windows XP, if my code dereferenced null I would get a crash in debug and I could then easily identify where the bug was coming from. It seems that in Windows 7 (I'm running 64-bit), instead of crashing or creating any sort of notification, the code will si...

11
голосов
3ответов
1626 просмотров

C#: In what cases should you null out references?

The CLR Profiler can also reveal which methods allocate more storage than you expected, and can uncover cases where you inadvertently keep references to useless object graphs that otherwise could be reclaimed by GC. (A common problem design pattern is a software cache or lookup table of items ...

39
голосов
5ответов
134542 просмотров

PHP Check for NULL

Here is the below Code: $query = mysql_query("SELECT * FROM tablex"); if ($result = mysql_fetch_array($query)){ if ($result['column'] == NULL) { print "<input type='checkbox' />"; } else { print "<input type='checkbox' checked />"; } } If the values are NOT NULL i still g...

13
голосов
2ответов
618 просмотров

Can I get warnings for sending nil objects messages?

I'm aware that it's perfectly fine to send messages to nil objects in Objective-C. However, I am curious if there is any runtime support for flagging such situations. I can see this being useful in testing/debugging situations.

1
голосов
3ответов
264 просмотров

Is it a bad thing to override == and have an instance compare equal to null?

Background Let's say I have the following class: public class MyValue<T> { public T Value { get; set; } public static bool operator ==(MyValue<T> first, MyValue<T> second) { // if first and second are the same instance, they are equal if (object....

3
голосов
5ответов
272 просмотров

Which is the best practice to use in string in ASP.NET(C#)

I want to know which is the preferred way to declare a string in C#: string strEmpty = String.Empty;    or string strNull = null; Which practice is better or what is the difference between these statements.

6
голосов
3ответов
5720 просмотров

SQL: how to know if a field has "Allow nulls" checked or not checked by SQL command

I want to know which table's field are required or not required so I have to get "Allow nulls" state. How to do that?

170
голосов
16ответов
117681 просмотров

When should I use nil and NULL in Objective-C?

This is sample code: NSDictionary *myDictionary = [NSDictionary dictionary]; NSNumber *myNumber = [myDictionary valueForKey: @"MyNumber"]; NSLog(@"myNumber = %@", myNumber); // output myNumber = (null) if (myNumber == nil) NSLog(@"test 1 myNumber == nil"); if (myNumber == NULL) NSLog(@...

18
голосов
4ответов
40720 просмотров

When JavaScript returns null & undefined?

I have been using JavaScript for couple of years and never cared about the difference between null & undefined earlier, I always use undefined to validate the object existence. But recently I came through this article. Here they said JavaScript distinguishes between null, which is an obj...

7
голосов
5ответов
2565 просмотров

Delete NULL but no compile error

I'm confused why the following C++ code can compile. Why does a call to delete the method of 0 not produce any error?! int *arr = NULL; // or if I use 0, it's the same thing delete arr; I did try to run it, and it did not give me any error at all...

0
голосов
1ответов
1183 просмотров

Internet Explorer Post Data Bug - ASP.NET MVC

I just started playing with MVC and I've run into a roadblock. I'm using a partial view as a User Login flyout on the header of each page using OpenID. When the user clicks on the provider (similar to stackoverflow) it authenticates and then either returns to the calling page or redirects to th...

4
голосов
2ответов
6224 просмотров

Java: Treemap - forbid null?

Is there a way to prevent a treemap from accepting null values, or do I need to do a check every time I enter something?

2
голосов
7ответов
2149 просмотров

String says its not null but then later throw NullPointerException

OMG. I have a little project to do and the Strings are killing me! Now, I have a String which is null (is taken the value from invoking getParameter() from a servlet). The problem is that, I'm trying to see if it's null, and, even if it's null, in the program is telling me that is not null, but...

2
голосов
3ответов
5081 просмотров

Help - Null Object error when using stage.addEventListener (ScrollBar)

Hey guys, hoping for some help with this :( been stuck on it for a couple days now. I'm creating a ScrollBar using Lee Brimelow's ScrollBar class. I've had to modify it to work inside of my Class files and think I'm on the right track, but I'm getting the dreaded: Error #1009: Cannot access a ...

4
голосов
2ответов
9379 просмотров

Set a String to "" or leave it null?

I have some String variables which are getting the values from invoking the function getParameter() and some of this variables will probably be null. Later, I will evaluate this variables using equals() method. Should I set all the String variables to the empty String ("") if they are null to a...

12
голосов
4ответов
4735 просмотров

Does mysql 5.0 index null values?

I realize that the exact question has been asked before on stack overflow with only a vaguely conclusive answer: link So here it is again. Table A: Has an integer column which is nullable, along with an index. Query: SELECT * FROM table WHERE column IS NULL LIMIT 10; Will an index be use...

2
голосов
3ответов
622 просмотров

How should I handle invalid user input in this case?

I'm writing a plug-in for a geometric modeling program, and I have an abstract class that is based off a Curve object. The curve is only considered valid if it is planar, closed, and does not intersect itself. I then have a chain of other methods that reference this curve that do things like ma...

3
голосов
3ответов
5864 просмотров

AS3 -TypeError #1009 - any easy way to find out *which* object reference is null?

We all get "TypeError #1009 Cannot access a property or method of a null object reference" now and then - no big deal, but sometimes frustrating to debug. Flash gives you the call stack (which is a start), but leaves it up to you to figure out where the null object is - is it possible to find o...

0
голосов
2ответов
260 просмотров

iPhone properties getting set to nil

I set a property with this declaration: @property (nonatomic,retain) NSDictionary *itemData; to a dictionary with 1 key - val pair. The table view in my view then gets the one value for the dictionary fine as a section header. But when I go back to access that very same value, it is nil. Any ...

2
голосов
4ответов
309 просмотров

Why can I select something out of left join on a NULL column?(with contrived example to reproduce it locally,probably a bug!)

VERSION I'm using Server version: 5.1.36-community-log MySQL Community Server (GPL) I've finally contrived a easy example to reproduce it easily! setup: create table t1(id integer unsigned,link integer unsigned); create table t2(id integer unsigned auto_increment,primary key(id)); create table...

0
голосов
2ответов
376 просмотров

BST insert in C++

I'm learning C++ and writing a binary search tree. The following is the code I wrote for my insert method. BSTNode * BST::Insert(const std::string & v) { BSTNode *n = !root ? root = new BSTNode(v) : Insert_Helper(v,root); if(n) size++; return n; } BSTNode * BST::Insert_Helper(co...

1
голосов
4ответов
1842 просмотров

WPF custom control XAML null error

Yet another strange WPF error: I have a custom control in a simple XAML page. The project builds and runs perfectly, with no errors. Here's the XAML: <Window x:Class="Grapher2.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com...

8
голосов
8ответов
11123 просмотров

Iterate through method's parameters for validation purposes

I've been thinking that it would be useful to be able to do such a thing, for example, to check the parameters for null references and eventually throw an exception. This would save some typing and also would make it impossible to forget to add a check if a new parameter is added.

2
голосов
2ответов
3784 просмотров

Default values for COUNT in MySQL

I have a table looking something like this: +-------+-----+ |country|prop1| +-------+-----+ |RO | 1 | |RO | 2 | |UK | 1 | |IT | 2 | +-------+-----+ I want to count the rows for which the prop1 is not null and I use the following select: SELECT `country`, COUNT(*) as nu...

4
голосов
2ответов
2971 просмотров

ActiveRecord - Self Referencing Associations

I'm a total Ruby/Rails/AR noob. I have a very basic sort of database schema that I can't seem to figure out the best way to represent in the Rails Way. Table Post String title, author Text content Timestamp posted Post parent The idea here is that top level posts will have pa...

15
голосов
6ответов
108325 просмотров

Array of char* should end at '\0' or "\0"?

Lets say we have an array of char pointers char* array[] = { "abc", "def" }; Now what should be put in the end ? char* array[] = { "abc", "def", 'char* array[] = { "abc", "def", "array[ index ] != 'array[ index ] != "12321"; '; " }; ' }; or 12321 Though, both works. We only have to put th...

0
голосов
1ответов
13765 просмотров

SQL max and null

I am trying to get the null value in the USAGE_START_DATE column. So far, what is i got is the unique max records of those with value in the USAGE START DATE column, and could not find any the records with nulls in the USAGE START DATE. I already tried ISNULL, COALESCE, NVL, NZ. I got 2 tabl...

2
голосов
5ответов
13202 просмотров

Can't convert nil to string -- edited to restate all the failing attempts

At a point in my code, I expect current_part to sometimes be nil, and I want to run some code (inside an if block) when that's not the case. Using script/server --debugger, I've established that current_part is in fact nil at that point when the following errors occur. All the following version...

51
голосов
10ответов
43799 просмотров

How to select an empty result set?

I'm using a stored procedure in MySQL, with a CASE statement. In the ELSE clause of the CASE ( equivalent to default: ) I want to select and return an empty result set, thus avoiding to throw an SQL error by not handling the ELSE case, and instead return an empty result set as if a regular query...

2
голосов
5ответов
18503 просмотров

MySQL Default Value Issue

In MySQL, the default value for a Integer Field is 0. During insertion the value for that field is NULL and the NULL gets inserted. I do some arithmetic manipulation like addition, multipilcation, division using that field's value. This results in error as NULL got inserted. How to resolve this p...