What's the best way of writing robust code so that a variable can be checked for null and blank.
e.g.
string a;
if((a != null) && (a.Length() > 0))
{
//do some thing with a
}
Why do this:
// If parameter cannot be cast to Point return false.
TwoDPoint p = obj as TwoDPoint;
if ((System.Object)p == null)
{
return false;
}
Instead of this:
// If parameter cannot be cast to Point return false.
TwoDPoint p = obj as TwoDPoint;
if (p == null)
{
return false;
}
I don't understand why you'd ever write ((System.Object)p)?
Regards,
Dan
Which approach is better to use:
BoundField.NullDisplayText isn't set. NULL-case is foreseen in SQL query, i.e. SELECT ISNULL(amount, 0) FROM table
or
BoundField.NullDisplayText is set, e.g. "0.00 %". NULL-case isn't foreseen in SQL query, i.e. SELECT amount FROM table
What do you think?
I'm using the following code to hide stderr on Linux/OSX for a Python library I do not control that writes to stderr by default:
f = open("/dev/null","w")
zookeeper.set_log_stream(f)
Is there an easy cross platform alternative to /dev/null? Ideally it would not consume memory since this is a long running process.
My OCSP client is sending me the following HTTP request:
POST <NULL> HTTP/1.0
Content-Type: application/ocsp-request
Content-Length: 120
The NULL is not mentioned in the RFC for HTTP 1.0. Does that make this a malformed request?
I have a model called user which has_one email. I put the foreign key (NOT NULL) inside users table.
Now I'm trying to save it in the following way:
@email = Email.new(params[:email])
@email.user = User.new(params[:user])
@email.save
This raises a db exception, because the foreign key constraint is not met (NULL is inserted into email_id). How can I elegantly solve this or is my data modeling wrong?
I have the following structure in a Java Web Application:
TheProject
-- [Web Pages]
-- -- [WEB-INF]
-- -- -- abc.txt
-- -- index.jsp
-- [Source Packages]
-- -- [wservices]
-- -- -- WS.java
In WS.java, I am using the following code in a Web Method:
InputStream fstream = this.getClass().getResourceAsStream("abc.txt");
But it is always returning a null. I need to read from that file, and I read that if you put the files in WEB-INF, you can access them with getResourceAsStream, yet the method is always returning a null.
Any ideas of what I may be doing wrong?
can someone please help me with this javascript:void(null)
I found it used in link buttons as follows
<a onclick="ProcessResponse()" href="javascript:void(null)" >Accept Data</a>
Good Morning,
Say I have an insert statement:
Insert INTO tblTest (fieldOne,FieldTwo,fieldThree) VALUES ('valueOne','valueTwo','null')
This statement doesn't seem to want to insert a null value into the database... I have also tried to insert the word "nothing".
Has anyone any ideas how to make this work? I am using SQL server 2005.
Hi,
Is there any function to replace the special characters by null in informatica
if we used replacestr function, i think we should specify all special characters
as follows replacestr(input,'!','~','@','#','$','%','^','&','*',null)
But we dont know what are teh special characters will be coming as input.
can u please let me know that which function will be suitable.
In my project I observed that in a FormClosed method (that handles FormClosed event)
is set MdiParent = Nothing (null).
This code makes (? no idea why) that OnLoad(method) on some child panels is raised.
Is there any sense to set MdiParent to null (Nothing) in FormClosed?
I have a simple problem, I think, but I have googled and can't find the solution. I have a cube that has MeasureA, MeasureB and MeasureC. Not all three measures have values for each record, sometimes they can be null, it's depending if it was applicable.
Now for my totals, I need to average but the average must not take nulls into account. Any help will be much appreciated. When I view the measures, the null values show as zeros.
When running a groovy script from Eclipse, the following line:
def rootLoader = this.class.getClassLoader().getRootLoader()
is null. When I run the script directly from command line, this is not null. How can I find out why this happens?
I've set up a view which combines all the data across several tables. Is there a way to write this so that only columns which contain non-null data are displayed, and those columns which contain all NULL values are not included?
Dunno why it is...heres the coding for it.
http://pastebin.org/301343
I know theres a lot of repetitiveness in the coding...but its because the arrays were retuning null so I got tired of messing with them.
Everything works until it reaches line 224, which returns null values.
Is it a good practice to set stream references to null after closing them? Would this release resources in any way?
Example:
BufferedReader input= new BufferedReader(new FileReader("myfile.txt"));
// code
input.close();
input = null;
// possible more code
How can I validate a String null or empty using the c tags of JSLT.
I have a variable of name var1 and I can display it, but I want to add a comparator for validate it.
I want to validate when is different of null or empty (my values are string).
I have seen people using the following conditions interchangeably.
String name;
//some code
if(name != null)
//or if(null != name)
So is there any difference in this? or both are same?
I am asking this here because, i heard that there is some difference in these, but don't know what.
Thanks
Which approach is better to use:
BoundField.NullDisplayText isn't set. NULL-case is foreseen in SQL query, i.e. SELECT ISNULL(amount, 0) FROM table
or
BoundField.NullDisplayText is set, e.g. "0.00 %". NULL-case isn't foreseen in SQL query, i.e. SELECT amount FROM table
What do you think?
Hi
I have asked this question before in this forum and they told me that it will retun an empty result set,I want to know that if I set the column with null values it will retun an empty result set?also the ANSI_NULLS is OFF ,thanks
SELECT 'A' FROM T WHERE A = NULL;
char *p,*p1,*p2,*p3,*p4;
for(;;)
{
if((p=malloc(10))!=NULL && (p1=malloc(20))!=NULL ......)
break;
}
Writing if(........) is too boring and long, are there any ways to make it simpler?