|
I have a class with a static public property called "Info". via reflection i want to get this properties value, so i call:
PropertyInfo pi myType.GetProperty("Info"); string info = (string) pi.GetValue(null, null);
this works fine as long as the property...
Started by joreg on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
My first guess would PluginInfo _PluginInfo = null; public static IPluginInfo PluginInfo { get { if (_PluginInfo == null = "PluginVersion"; } ....
That way you can break the debugger and look at the return value before it's lost.
|
|
I need to do a comparaison between an object and NULL. When the object is not NULL I fill it with some data.
Here is the code :
if (region != null) { .... }
This is working but when looping and looping sometime the region object is NOT null (I can see...
Started by Daok on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
R2)) { // handles if both are null as well as object identity return true; } if ((object)r1 == null || (object)r2 == null) { return false; } return (r1.Cmr.CompareTo(r2.Cmr) == 0 && r1.Id == r2.Id operator !....
|
|
I have a link query that looks like this...
var duration = Level3Data.AsQueryable().Sum(d => d.DurationMonths);
If all the d.DurationMonths values are null the Sum returns 0. How can I make the Sum return null if all the d.DurationMonths are null? ...
Started by Si Keep on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
As you indicated = Level3Data.AsQueryable(); var duration = q.All(d => d.DurationMonths == null) ? null : q.Sum(d => = Level....
) ? Level3Data.AsQueryable().Sum(d => d.DurationMonths) : null;
Using Sum alone, this is impossible.
|
Ask your Facebook Friends
|
So let's say you have a function that returns a date
Date myFunc(paramA, paramB){ //conditionally return a date?
}
So is it appropriate to return null from this function? This seems ugly because it forces clients to check for null.
The "null object" pattern...
Started by DanielHonig on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
Document that it could return null, however(); }....
However if you want to return null on an error, consider throwing into the function far more than just getting a null returned.
null is quite acceptable.
|
|
How do you return 0 instead of null when running the following command:
SELECT MAX(X) AS MaxX FROM tbl WHERE XID = 1
(Assuming there is no row where XID=1)
Started by cf_PhillipSenn on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
MAX(X), 0, MAX(X)) AS MaxX FROM tbl WHERE XID = 1
or
SELECT CASE MAX(X) WHEN NULL THEN 0 ELSE MAX(X use COALESCE ( expression [ ,...n ] ) - returns first non-null like:
SELECT COALESCE(MAX(X),0.
|
|
I have this code
$return = $ep->$method($params); if ($return === null) { throw new Exception('Endpoint has no return value'); } return $return;
Is there any way to distinguish between a method that returns null and a method that does not return anything...
Started by Bart van Heukelom on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Use null
and you can use isEmpty
see php....
You can return another value? Boolean true possibly, and check for that or null.
When no return value is set the function automatically returns null.
It's not possible.
|
|
Is it possible for a VB.net function with a return type of integer to return null ?
Started by mat690 on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Both dommer and Mitch....
If you're strictly talking about a null reference (C#'s version of null) then the answer is No.
You'll need a return type of Nullable(Of Integer).
Only if it is defined as returning a nullable integer.
|
|
Hi all,
I have a, I think fairly easy, question, but I can't figure out what I'm doing wrong. I have a function which i call with PHP's function eval . I'm expecting an, selfbuilt, ArrayList to get as a result. But instead when I use gettype I see the...
Started by Ben Fransen on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
The return....
Although bar() returns a value foo=eval('bar();'); var_dump($x); $x=eval('return bar();'); var_dump($x);
prints
NULL int(1() does not.
() { return 1; } $x=foo(); var_dump($x);
the output will be `NULL'.
|
|
I have a method that is suppose to return an object if it is found.
If it is not found, should I:
a) return null b) throw an exception c) other
Started by Robert on
, 32 posts
by 32 people.
Answer Snippets (Read the full thread at stackoverflow):
Generally it should return null then:
Object....
Client code can then decide what to do.
The (for lack, then it's best to return null.
I prefer to just return a null, and rely on the caller to handle it appropriately.
|
|
Var adminCov = db.SearchAgg_AdminCovs.SingleOrDefault(l => l.AdminCovGuid == covSourceGuid);
adminCov keeps coming back null. When I run SQL profiler, I can see the generated linq, when I past that into management Studio, I get the result I expect....
Started by Kettenbach on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
It will return null when.
SingleOrDefault will return null if there are no matches FirstOrDefault to get the first match if there is at least one match.
Or more than one record matching the criteria.
|