Search Results

Search found 20401 results on 817 pages for 'null coalescing operator'.

Page 9/817 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Why does null need to be casted?

    - by BlueRaja The Green Unicorn
    The following code does not compile: //int a = ... int? b = (int?) (a != 0 ? a : null); In order to compile, it needs to be changed to int? b = (a != 0 ? a : (int?) null); Since both b = null and b = a are legal, this doesn't make sense to me. Why does null need to be casted, and why can't we simply cast the whole expression (which I know is legal in other cases)?

    Read the article

  • LINQ-to-entities - Null reference

    - by BlueRaja
    I could swear this was working the other day: var resultSet = (from o in _entities.Table1 where o.Table2.Table3.SomeColumn == SomeProperty select o ).First(); SelectedItem = resultSet.Table2.SomeOtherColumn; I am getting a null reference exception on the last line: resultSet.Table2 is null. Not only am I sure that all the foreign keys and whatnot have the correct values, but I don't see how Table2 could be null, since o.Table2.Table3.SomeColumn == SomeProperty. resultSet is being returned with all its properties set to the correct values, with the exception that Table2 is null.

    Read the article

  • linq null parameter

    - by kusanagi
    how can i do the code static string BuildMenu(List<Menu> menu, int? parentId) { foreach (var item in menu.Where(i => i.ParentMenu == parentId || i.ParentMenu.MenuId == parentId).ToList()) { } } return BuildMenu(menuList,null); so if parentId==null then return only records i = i.ParentMenu == null but when parentId is 0 then return records with i.ParentMenu.MenuId == parentId

    Read the article

  • Identifying and removing null characters in UNIX

    - by fahdshariff
    I have a text file containing unwanted null characters. When I try to view it in I see ^@ symbols, interleaved in normal text. How can I: a) Identify which lines in the file contains null characters? I have tried grepping for \0 and \x0, but this did not work. b) Remove the null characters? Running strings on the file cleaned it up, but I'm just wondering if this is the best way? Thanks

    Read the article

  • Compilers behave differently with a null parameter of a generic method

    - by Eyal Schneider
    The following code compiles perfectly with Eclipse, but fails to compile with javac: public class HowBizarre { public static <P extends Number, T extends P> void doIt(P value) { } public static void main(String[] args) { doIt(null); } } I simplified the code, so T is not used at all now. Still, I don't see a reason for the error. For some reason javac decides that T stands for Object, and then complains that Object does not conform to the bounds of T (which is true): HowBizarre.java:6: incompatible types; inferred type argument(s) java.lang.Number,java.lang.Object do not conform to bounds of type variable (s) P,T found : <P,T>void required: void doIt(null); ^ Note that if I replace the null parameter with a non-null value, it compiles fine. Which of the compilers behaves correctly and why? Is this a bug of one of them?

    Read the article

  • How Oracle 10g evaluates NULL in boolean expressions

    - by Phani Kumar PV
    if not (i_ReLaunch = 1 and (dt_enddate is not null)) How this epression will be evaluated in Oracle 10g when the input value of the i_ReLaunch = null and the value of the dt_enddate is not null it is entering the loop. According to the rules in normal c# and all it should not enter the loop as it will be as follows with the values. If( not(false and (true)) = if not( false) =if( true) which implies it should enters the loop But it is not happening Can someone let me know if i am wrong at any place

    Read the article

  • Class Assignment Operators

    - by Maxpm
    I made the following operator overloading test: #include <iostream> #include <string> using namespace std; class TestClass { string ClassName; public: TestClass(string Name) { ClassName = Name; cout << ClassName << " constructed." << endl; } ~TestClass() { cout << ClassName << " destructed." << endl; } void operator=(TestClass Other) { cout << ClassName << " in operator=" << endl; cout << "The address of the other class is " << &Other << "." << endl; } }; int main() { TestClass FirstInstance("FirstInstance"); TestClass SecondInstance("SecondInstance"); FirstInstance = SecondInstance; SecondInstance = FirstInstance; return 0; } The assignment operator behaves as-expected, outputting the address of the other class. Now, how would I actually assign something from the other class? For example, something like this: void operator=(TestClass Other) { ClassName = Other.ClassName; }

    Read the article

  • Alter Dilemma : How to use to set Primary and other attributes.

    - by Rachel
    I have following table in database AND I need to alter it to below mentioned schema. Initially I was drop the current database and creating new one using the create but I am not supposed to do that and use ALTER but am not sure as to how can I use ALTER to add primary key and other constraints. Any Suggestions !!! Code Current: CREATE TABLE `details` ( `KEY` varchar(255) NOT NULL, `ID` bigint(20) NOT NULL, `CODE` varchar(255) NOT NULL, `C_ID` bigint(20) NOT NULL, `C_CODE` varchar(64) NOT NULL, `CCODE` varchar(255) NOT NULL, `TCODE` varchar(255) NOT NULL, `LCODE` varchar(255) NOT NULL, `CAMCODE` varchar(255) NOT NULL, `OFCODE` varchar(255) NOT NULL, `OFNAME` varchar(255) NOT NULL, `PRIORITY` bigint(20) NOT NULL, `STDATE` datetime NOT NULL, `ENDATE` datetime NOT NULL, `INT` varchar(255) NOT NULL, `PHONE` varchar(255) NOT NULL, `TV` varchar(255) NOT NULL, `MTV` varchar(255) NOT NULL, `TYPE` varchar(255) NOT NULL, `CREATED` datetime NOT NULL, `MAIN` varchar(255) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Desired: CREATE TABLE `details` ( `id` bigint(20) NOT NULL, `code` varchar(255) NOT NULL, `cid` bigint(20) NOT NULL, `ccode` varchar(64) NOT NULL, `c_code` varchar(255) NOT NULL, `tcode` varchar(255) NOT NULL, `lcode` varchar(255) NOT NULL, `camcode` varchar(255) NOT NULL, `ofcode` varchar(255) NOT NULL, `ofname` varchar(255) NOT NULL, `priority` bigint(20) NOT NULL, `stdate` datetime NOT NULL, `enddate` datetime NOT NULL, `list` varchar(255) NOT NULL, `name` varchar(255) NOT NULL, `created` datetime NOT NULL, `date` datetime NOT NULL, `ofshn` int(20) NOT NULL, `ofcl` int(20) NOT NULL, `ofr` int(20) NOT NULL, PRIMARY KEY (`code`,`ccode`,`list`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Thanks !!!

    Read the article

  • MessageBroker.getMessageBroker(null) getting null pointer Exception

    - by Shital
    I am creating Dynamic Destinations MessageBroker broker = MessageBroker.getMessageBroker(null); MessageService service = (MessageService) broker.getService("message-service"); MessageDestination destination = (MessageDestination) service.createDestination("Group1"); if (service.isStarted()) { destination.start(); } But I am getting Null Pointer Exception MessageBroker broker = MessageBroker.getMessageBroker(null); Can Anyone Help Me

    Read the article

  • R: preventing unlist to drop NULL values

    - by nico
    I'm running into a strange problem. I have a vector of lists and I use unlist on them. Some of the elements in the vectors are NULL and unlist seems to be dropping them. How can I prevent this? Here's a simple (non) working example showing this unwanted feature of unlist a = c(list("p1"=2, "p2"=5), list("p1"=3, "p2"=4), list("p1"=NULL, "p2"=NULL), list("p1"=4, "p2"=5)) unlist(a) p1 p2 p1 p2 p1 p2 2 5 3 4 4 5

    Read the article

  • node to traverse cannot be null (Hibernate SQL)

    - by tiswas
    I'm performing a SQL query through hibernate, which looks like: SELECT thi FROM track_history_items thi JOIN artists art ON thi.artist_id = art.id WHERE thi.type = "TrackBroadcast" GROUP BY art.name ORDER thi.createdAt DESC but I'm getting the message that 'Node to traverse cannot be null!'. Anyone know what could be causing this? --EDIT-- I'm pretty sure that this problem is being caused by the possibility of artist_id to be null. However, I can't prevent this, so can I just skip the rows track_history_item rows which have a null artist_id?

    Read the article

  • SSIS Script Component, Allow Null values

    - by user2471943
    I have a SSIS package that I am programming and my script component won't allow null column inputs. I have checked the box to keep nulls in the flat file source component. My program is running well until my script component where I get the error "The column has a null value" (super vague, I know). The column currently throwing the error is an "int" valued column and is used for aggregations in my script. I could make the null values 0s or to say "NULL" but I'd prefer to just leave them blank. Any advice on how to handle this problem would be greatly appreciated! Thanks in advance! I am using SQL Server BIDS 2008.

    Read the article

  • To "null" or not to "null" my class's attributes

    - by Helper Method
    When I write a class in Java, I like to initialize the attributes which are set to a default value directly and attributes which are set by the caller in the constructor, something like this: public class Stack<E> { private List<E> list; private size = 0; public Stack(int initialCapacity) { list = new ArrayList<E>(initialCapacity); } // remainder omitted } Now suppose I have a Tree class: public class Tree<E> { private Node<E> root = null; // no constructor needed, remainder omitted } Shall I set the root attribute to null, to mark that it is set to null by default, or omit the null value?

    Read the article

  • geom_rect and NULL

    - by csgillespie
    I've been looking at the geom_rect example in section 5.10 of the ggplot2 book and don't understand the purpose of the NULL's in the aes function. For example, using the mpg data: g = ggplot(data=mpg, aes(x=displ, y=hwy)) + geom_point() #Produces a plot with a transparent filled region g + geom_rect(aes(NULL, NULL), alpha=0.1,xmin=5, xmax=7, ymin=10, ymax=45, fill="blue") #Solid filled region (v0.9) or nothing in v0.8 g + geom_rect(alpha=0.1,xmin=5, xmax=7, ymin=10, ymax=45, fill="blue") My understanding is that the NULL's are resetting the x & y mapping, but I don't see why this should affect the transparency.

    Read the article

  • set arraylist element as null

    - by Jessy
    The first index is set to null (empty), but it doesn't print the right output, why? //set the first index as null and the rest as "High" String a []= {null,"High","High","High","High","High"}; //add array to arraylist ArrayList<Object> choice = new ArrayList<Object>(Arrays.asList(a)); for(int i=0; i<choice.size(); i++){ if(i==0){ if(choice.get(0).equals(null)) System.out.println("I am empty"); //it doesn't print this output } }

    Read the article

  • NULL pointer comparison fails

    - by Ilya
    Hello, I'm initializing in a class a pointer to be NULL. Afterwards I check if it is NULL in the same class. But it's not always 0x0. Sometimes it's 0x8 or 0xfeffffff or 0x3f800000 or 0x80 or other strange stuff. In most case the pointer is 0x0 but sometimes it gets altered somehow. I'm sure that I'm not changing it anywhere in my code. Is there a way it gets changed by "itself"? Here's my code: MeshObject::MeshObject() { mesh.vertexColors = NULL; } MeshObject::MeshObject(const MeshObject &_copyFromMe) { SimpleLog("vertexColors pointer: %p", _copyFromMe.mesh.vertexColors); if (_copyFromMe.mesh.vertexColors != NULL) { SimpleLog("vertexColors"); this->mesh.vertexColors = new tColor4i[_copyFromMe.mesh.vertexCount]; memcpy(this->mesh.vertexColors, _copyFromMe.mesh.vertexColors, _copyFromMe.mesh.vertexCount * sizeof(tColor4i) ); } } My application crashes, because vertexColors wasn't initialized and is being copied. However it is NULL and shouldn't be copied. Thanks.

    Read the article

  • List with non-null elements ends up containing null. A synchronization issue?

    - by Alix
    Hi. First of all, sorry about the title -- I couldn't figure out one that was short and clear enough. Here's the issue: I have a list List<MyClass> list to which I always add newly-created instances of MyClass, like this: list.Add(new MyClass()). I don't add elements any other way. However, then I iterate over the list with foreach and find that there are some null entries. That is, the following code: foreach (MyClass entry in list) if (entry == null) throw new Exception("null entry!"); will sometimes throw an exception. I should point out that the list.Add(new MyClass()) are performed from different threads running concurrently. The only thing I can think of to account for the null entries is the concurrent accesses. List<> isn't thread-safe, after all. Though I still find it strange that it ends up containing null entries, instead of just not offering any guarantees on ordering. Can you think of any other reason? Also, I don't care in which order the items are added, and I don't want the calling threads to block waiting to add their items. If synchronization is truly the issue, can you recommend a simple way to call the Add method asynchronously, i.e., create a delegate that takes care of that while my thread keeps running its code? I know I can create a delegate for Add and call BeginInvoke on it. Does that seem appropriate? Thanks.

    Read the article

  • how to count NULL categories in one SQL question

    - by grzes
    hi, i have a blog application were Post belongsTo Category and Category hasMany Post Post can have a Category or not - in latter case NULL value is present in Post.category_id field. Now i would like to have following category count with single SQL query category|post_count -------------- PHP | 2 JavaScript | 4 SomeOtherCat | 1 NULL | 3 The clue here is that i also want to count posts without category (NULL row above). Is it posibble with one SQL query?

    Read the article

  • Why doesn't list.get(0).equals(null) work?

    - by Jessy
    The first index is set to null (empty), but it doesn't print the right output, why? //set the first index as null and the rest as "High" String a []= {null,"High","High","High","High","High"}; //add array to arraylist ArrayList<Object> choice = new ArrayList<Object>(Arrays.asList(a)); for(int i=0; i<choice.size(); i++){ if(i==0){ if(choice.get(0).equals(null)) System.out.println("I am empty"); //it doesn't print this output } }

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >