Search Results

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

Page 2/817 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Null object that is not null

    - by Guillaume
    Hello, I use 2 threads to act like a produce/consumer using double queue (http://www.codeproject.com/KB/threads/DoubleQueue.aspx). Sometimes in my 2nd thread, I get an object that is NULL but it should not be as I filled it in the first thread. I tried this: if(myObject.Data == null) { Console.WriteLine("Null Object") // <-- Breakpoint here } When I my break point hits, I can watch myObject.Data and indeed it's NULL, but when I hit F10 and then go to the next line (which is } ) myObject.Data is not NULL. I also added a lock on myObject before if .... to be sure that no one whould use this object. How is that possible and what can I do ?

    Read the article

  • Returning null vs Throwing exceptions

    - by Svish
    Is in a bit of disagreement with a more experienced developer on this issue, and was wondering what you guys here think about this. Environment is Java, EJB 3, services, etc. The code I wrote calls a service to get things and to create things. Problem was that I got null pointer exceptions in places that didn't make sense. For example when I asked the service to create an object, I got null back. And when I tried to look up an object with an id I knew existed, I still got null back. Was like it was ignoring me. Spent some time trying to figure out what was wrong in my code (since I'm less experienced I usually assume I have messed up). Turns out the reason was security. If the user principal using my service didn't have the right permissions to use the service I called from my service, then that service simply returned null. The services that are here already are usually not documented either, so this is just something you have to know... somehow... So here is the thing: I mean that this is rather confusing as a developer interacting with this service. To me it would make much more sense if that service thew an exception which would tell me that hey, you don't have the proper permissions to get info about this thing or to create this new thing. I would then immediately know why my service wasn't working as expected. However, he argued that asking is not wrong. Exceptions should only be thrown when there is an error and asking for a thing is not an error. Even if you don't have permission to "see" that the thing you asked for. The things are often looked up in a GUI by users and for those users not having the right permissions, these things simply "do not exist". So, in short: Asking is not wrong, hence no exception. Get methods return null because to those users those things "doesn't exist". Create methods return null because nothing was created, since the user wasn't allowed to create anything. So, what do you guys think? Is this normal and/or good practice? I prefer exceptions as I prefer throwing and catching exceptions because I find it much easier to know what's going on. So I would for example also prefer to throw a NotFoundException if you asked for an id which didn't exist, rather than returning null. Anyways, just curious to what others think about this as I'm not the most experienced developer yet.

    Read the article

  • Negate the null-coalescing operator

    - by jhunter
    I have a bunch of strings I need to use .Trim() on, but they can be null. It would be much more concise if I could do something like: string endString = startString !?? startString.Trim(); Basically return the part on the right if the part on the left is NOT null, otherwise just return the null value. I just ended up using the ternary operator, but is there anyway to use the null-coalescing operator for this purpose?

    Read the article

  • Can operator<< in derived class call another operator<< in base class in c++?

    - by ivory
    In my code, Manager is derived from Employee and each of them have an operator<< override. class Employee{ protected: int salary; int rank; public: int getSalary()const{return salary;} int getRank()const{return rank;} Employee(int s, int r):salary(s), rank(r){}; }; ostream& operator<< (ostream& out, Employee& e){ out << "Salary: " << e.getSalary() << " Rank: " << e.getRank() << endl; return out; } class Manager: public Employee{ public: Manager(int s, int r): Employee(s, r){}; }; ostream& operator<< (ostream& out, Manager& m){ out << "Manager: "; cout << (Employee)m << endl; //can not compile, how to call function of Employee? return out; } I hoped cout << (Employee)m << endl; would call ostream& operator<< (ostream& out, Employee& e), but it failed.

    Read the article

  • Java conditional operator ?: result type

    - by Wangnick
    I'm a bit puzzled about the conditional operator. Consider the following two lines: Float f1 = false? 1.0f: null; Float f2 = false? 1.0f: false? 1.0f: null; Why does f1 become null and the second statement throws a NullPointerException? Langspec-3.0 para 15.25 sais: Otherwise, the second and third operands are of types S1 and S2 respectively. Let T1 be the type that results from applying boxing conversion to S1, and let T2 be the type that results from applying boxing conversion to S2. The type of the conditional expression is the result of applying capture conversion (§5.1.10) to lub(T1, T2) (§15.12.2.7). So for false?1.0f:null T1 is Float and T2 is the null type. But what is the result of lub(T1,T2)? This para 15.12.2.7 is just a bit too much ... BTW, I'm using 1.6.0_18 on Windows. PS: I know that Float f2 = false? (Float) 1.0f: false? (Float) 1.0f: null; doesn't throw NPE.

    Read the article

  • Implementing operator< in C++

    - by Vulcan Eager
    I have a class with a few numeric fields such as: class Class1 { int a; int b; int c; public: // constructor and so on... bool operator<(const Class1& other) const; }; I need to use objects of this class as a key in an std::map. I therefore implement operator<. What is the simplest implementation of operator< to use here?

    Read the article

  • MySQL Database Query Problem

    - by moustafa
    I need your help!!!. I need to query a table in my database that has record of goods sold. I want the query to detect a particular product and also calculate the quantity sold. The product are 300 now, but it would increase in the future. Below is a sample of my DB Table #---------------------------- # Table structure for litorder #---------------------------- CREATE TABLE `litorder` ( `id` int(10) NOT NULL auto_increment, `name` varchar(50) NOT NULL default '', `address` varchar(50) NOT NULL default '', `xdate` date NOT NULL default '0000-00-00', `ref` varchar(20) NOT NULL default '', `code1` varchar(50) NOT NULL default '', `code2` varchar(50) NOT NULL default '', `code3` varchar(50) NOT NULL default '', `code4` varchar(50) NOT NULL default '', `code5` varchar(50) NOT NULL default '', `code6` varchar(50) NOT NULL default '', `code7` varchar(50) NOT NULL default '', `code8` varchar(50) NOT NULL default '', `code9` varchar(50) NOT NULL default '', `code10` varchar(50) NOT NULL default '', `code11` varchar(50) character set latin1 collate latin1_bin NOT NULL default '', `code12` varchar(50) NOT NULL default '', `code13` varchar(50) NOT NULL default '', `code14` varchar(50) NOT NULL default '', `code15` varchar(50) NOT NULL default '', `product1` varchar(100) NOT NULL default '0', `product2` varchar(100) NOT NULL default '0', `product3` varchar(100) NOT NULL default '0', `product4` varchar(100) NOT NULL default '0', `product5` varchar(100) NOT NULL default '0', `product6` varchar(100) NOT NULL default '0', `product7` varchar(100) NOT NULL default '0', `product8` varchar(100) NOT NULL default '0', `product9` varchar(100) NOT NULL default '0', `product10` varchar(100) NOT NULL default '0', `product11` varchar(100) NOT NULL default '0', `product12` varchar(100) NOT NULL default '0', `product13` varchar(100) NOT NULL default '0', `product14` varchar(100) NOT NULL default '0', `product15` varchar(100) NOT NULL default '0', `price1` int(10) NOT NULL default '0', `price2` int(10) NOT NULL default '0', `price3` int(10) NOT NULL default '0', `price4` int(10) NOT NULL default '0', `price5` int(10) NOT NULL default '0', `price6` int(10) NOT NULL default '0', `price7` int(10) NOT NULL default '0', `price8` int(10) NOT NULL default '0', `price9` int(10) NOT NULL default '0', `price10` int(10) NOT NULL default '0', `price11` int(10) NOT NULL default '0', `price12` int(10) NOT NULL default '0', `price13` int(10) NOT NULL default '0', `price14` int(10) NOT NULL default '0', `price15` int(10) NOT NULL default '0', `quantity1` int(10) NOT NULL default '0', `quantity2` int(10) NOT NULL default '0', `quantity3` int(10) NOT NULL default '0', `quantity4` int(10) NOT NULL default '0', `quantity5` int(10) NOT NULL default '0', `quantity6` int(10) NOT NULL default '0', `quantity7` int(10) NOT NULL default '0', `quantity8` int(10) NOT NULL default '0', `quantity9` int(10) NOT NULL default '0', `quantity10` int(10) NOT NULL default '0', `quantity11` int(10) NOT NULL default '0', `quantity12` int(10) NOT NULL default '0', `quantity13` int(10) NOT NULL default '0', `quantity14` int(10) NOT NULL default '0', `quantity15` int(10) NOT NULL default '0', `amount1` int(10) NOT NULL default '0', `amount2` int(10) NOT NULL default '0', `amount3` int(10) NOT NULL default '0', `amount4` int(10) NOT NULL default '0', `amount5` int(10) NOT NULL default '0', `amount6` int(10) NOT NULL default '0', `amount7` int(10) NOT NULL default '0', `amount8` int(10) NOT NULL default '0', `amount9` int(10) NOT NULL default '0', `amount10` int(10) NOT NULL default '0', `amount11` int(10) NOT NULL default '0', `amount12` int(10) NOT NULL default '0', `amount13` int(10) NOT NULL default '0', `amount14` int(10) NOT NULL default '0', `amount15` int(10) NOT NULL default '0', `totalNaira` double(20,0) NOT NULL default '0', `totalDollar` int(20) NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='InnoDB free: 4096 kB; InnoDB free: 4096 kB; InnoDB free: 409'; #---------------------------- # Records for table litorder #---------------------------- insert into litorder values (27, 'Sanyaolu Fisayo', '14 Adegboyega Street Palmgrove Lagos', '2010-05-31', '', 'DL 001', 'DL 002', 'DL 003', '', '', '', '', '', '', '', '', '', '', '', '', 'AILMENT & PREVENTION DVD- ENGLISH', 'AILMENT & PREVENTION DVD- HAUSA', 'BEAUTY CD', '', '', '', '', '', '', '', '', '', '', '', '', 800, 800, 3000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12800, 12800, 60000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '85600', 563), (28, 'Irenonse Esther', 'Lagos,Nigeria', '2010-06-01', '', 'DL 005', 'DL 008', 'FC 004', '', '', '', '', '', '', '', '', '', '', '', '', 'GET HEALTHY DVD', 'YOUR FUTURE DVD', 'FOREVER FACE CAP (YELLOW)', '', '', '', '', '', '', '', '', '', '', '', '', 1000, 900, 2000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2000, 1800, 6000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '9800', 64), (29, 'Kalu Lekway', 'Lagos, Nigeria', '2010-06-01', '', 'DL 001', 'DL 003', '', '', '', '', '', '', '', '', '', '', '', '', '', 'AILMENT & PREVENTION DVD- ENGLISH', 'BEAUTY CD', '', '', '', '', '', '', '', '', '', '', '', '', '', 800, 3000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2400, 18000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '20400', 133), (30, 'Dele', 'Ilupeju', '2010-06-02', '', 'DL 001', 'DL 003', '', '', '', '', '', '', '', '', '', '', '', '', '', 'AILMENT & PREVENTION DVD- ENGLISH', 'BEAUTY CD', '', '', '', '', '', '', '', '', '', '', '', '', '', 800, 3000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8000, 30000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '38000', 250);

    Read the article

  • The ternary (conditional) operator in C

    - by Bongali Babu
    What is the need for the conditional operator? Functionally it is redundant, since it implements an if-else construct. If the conditional operator is more efficient than the equivalent if-else assignment, why can't if-else be interpreted more efficiently by the compiler?

    Read the article

  • Overloading assignment operator in C++

    - by jasonline
    As I've understand, when overloading operator=, the return value should should be a non-const reference. A& A::operator=( const A& ) { // check for self-assignment, do assignment return *this; } It is non-const to allow non-const member functions to be called in cases like: ( a = b ).f(); But why should it return a reference? In what instance will it give a problem if the return value is not declared a reference, let's say return by value?

    Read the article

  • Why does operator<< not work with something returned by operator-?

    - by Felix
    Here's a small test program I wrote: #include <iostream> using namespace std; class A { public: int val; A(int _val=0):val(_val) { } A operator+(A &a) { return A(val + a.val); } A operator-(A &a) { return A(val - a.val); } friend ostream& operator<<(ostream &, A &); }; ostream& operator<<(ostream &out, A &a) { out<<a.val; return out; } int main() { A a(3), b(4), c = b - a; cout<<c<<endl; // this works cout<<(b-a)<<endl; // this doesn't return 0; } I can't seem to get why the line marked "this works" works and the one marked "this doesn't" doesn't. When I try to compile the program with the cout<<(b-a); line, here's what I get: [felix@the-machine C]$ g++ test.cpp test.cpp: In function ‘int main()’: test.cpp:26:13: error: no match for ‘operator<<’ in ‘std::cout << b.A::operator-(((A&)(& a)))’ /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:108:7: note: candidates are: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:117:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>, std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:127:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:165:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:169:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:173:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/bits/ostream.tcc:91:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:180:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/bits/ostream.tcc:105:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:191:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:200:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:204:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:209:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:213:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:221:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/ostream:225:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/bits/ostream.tcc:119:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_ostream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>] test.cpp:18:11: note: std::ostream& operator<<(std::ostream&, A&) [felix@the-machine C]$ Quite nasty.

    Read the article

  • Checking instance of non-class constrained type parameter for null in generic method

    - by casperOne
    I currently have a generic method where I want to do some validation on the parameters before working on them. Specifically, if the instance of the type parameter T is a reference type, I want to check to see if it's null and throw an ArgumentNullException if it's null. Something along the lines of: // This can be a method on a generic class, it does not matter. public void DoSomething<T>(T instance) { if (instance == null) throw new ArgumentNullException("instance"); Note, I do not wish to constrain my type parameter using the class constraint. I thought I could use Marc Gravell's answer on "How do I compare a generic type to its default value?", and use the EqualityComparer<T> class like so: static void DoSomething<T>(T instance) { if (EqualityComparer<T>.Default.Equals(instance, null)) throw new ArgumentNullException("instance"); But it gives a very ambiguous error on the call to Equals: Member 'object.Equals(object, object)' cannot be accessed with an instance reference; qualify it with a type name instead How can I check an instance of T against null when T is not constrained on being a value or reference type?

    Read the article

  • C# Conditional Operator Not a Statement?

    - by abelenky
    I have a simple little code fragment that is frustrating me: HashSet<long> groupUIDs = new HashSet<long>(); groupUIDs.Add(uid)? unique++ : dupes++; At compile time, it generates the error: Only assignment, call, increment, decrement, and new object expressions can be used as a statement HashSet.Add is documented to return a bool, so the ternary (?) operator should work, and this looks like a completely legitimate way to track the number of unique and duplicate items I add to a hash-set. When I reformat it as a if-then-else, it works fine. Can anyone explain the error, and if there is a way to do this as a simple ternary operator?

    Read the article

  • conditional operator in C question

    - by Seephor
    I just have a quick question about the conditional operator. Still a budding programmer here. I am given x = 1, y = 2, and z = 3. I want to know, why after this statement: y += x-- ? z++ : --z; That y is 5. The values after the statement are x = 0, y = 5, and z = 4. I know the way the conditional operator works is that it is formatted like this: variable = condition ? value if true : value if false. For the condition, y += x-- , how does y become 5? I can only see 2 (2 += 0) and 3 (2 += 1)(then x-- becomes zero) as possibilities. Any help is much appreciated. :)

    Read the article

  • Operator Overloading in C++ as int + obj

    - by Azher
    Hi Guys, I have following class:- class myclass { size_t st; myclass(size_t pst) { st=pst; } operator int() { return (int)st; } int operator+(int intojb) { return int(st) + intobj; } }; this works fine as long as I use it like this:- char* src="This is test string"; int i= myclass(strlen(src)) + 100; but I am unable to do this:- int i= 100+ myclass(strlen(src)); Any idea, how can I achieve this?? Thanks in advance. Regards,

    Read the article

  • C# ?? null coalescing operator

    - by anirudha
    the null coalescing operator is used for set the value when object is null. if object have some value that nothing change and still have their default value they have.  string str = "i am string";            string message = str ?? "it is null";   the message have same value as str variable because str not null. if str is null that message have value “it is null”; as declared in statement. coalescing operator does not work on nullable operator such as int?

    Read the article

  • wcf web service in post method, object properties are null, although the object is not null

    - by Abdalhadi Kolayb
    i have this problem in post method when i send object parameter to the method, then the object is not null, but all its properties have the default values. here is data module: [DataContract] public class Products { [DataMember(Order = 1)] public int ProdID { get; set; } [DataMember(Order = 2)] public string ProdName { get; set; } [DataMember(Order = 3)] public float PrpdPrice { get; set; } } and here is the interface: [OperationContract] [WebInvoke( Method = "POST", UriTemplate = "AddProduct", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json)] string AddProduct([MessageParameter(Name = "prod")]Products prod); public string AddProduct(Products prod) { ProductsList.Add(prod); return "return string"; } here is the json request: Content-type:application/json {"prod":[{"ProdID": 111,"ProdName": "P111","PrpdPrice": 111}]} but in the server the object received: {"prod":[{"ProdID": 0,"ProdName": NULL,"PrpdPrice": 0}]}

    Read the article

  • Oral Tradition Check: Two Hundred Meanings for "NULL" in SQL

    - by Thomas L Holaday
    Two decades ago, the topic of "NULL" came up in conversation with a scholarly colleague. As I remember it, he said that C.J.Date, in an essay critical of commercial implementations of SQL, had listed over two hundred meanings for NULL. To my regret, I did not persist the details; but finding that list has since been on my Bucket List. Has anyone else heard this legend? Was it perhaps not Date, but another critic of commercial implementations of SQL?

    Read the article

  • Determining distribution of NULL values

    - by AaronBertrand
    Today on the twitter hash tag #sqlhelp, @leenux_tux asked: How can I figure out the percentage of fields that don't have data ? After further clarification, it turns out he is after what proportion of columns are NULL. Some folks suggested using a data profiling task in SSIS . There may be some validity to that, but I'm still a fan of sticking to T-SQL when I can, so here is how I would approach it: Create a #temp table or @table variable to store the results. Create a cursor that loops through all...(read more)

    Read the article

  • Much ado about NULL: Exploiting a kernel NULL dereference

    <b>Ksplice:</b> "We think that it&#8217;s important for developers and system administrators to be more knowledgeable about the attacks that black hats regularly use to take control of systems, and so, today, we&#8217;re going to start from where we left off and go all the way to a working exploit for a NULL pointer dereference in a toy kernel module."

    Read the article

  • What is the difference between NULL in C++ and null in Java?

    - by Stephano
    I've been trying to figure out why C++ is making me crazy typing NULL. Suddenly it hits me the other day; I've been typing null (lower case) in Java for years. Now suddenly I'm programming in C++ and that little chunk of muscle memory is making me crazy. Wikiperipatetic defines C++ NULL as part of the stddef: A macro that expands to a null pointer constant. It may be defined as ((void*)0), 0 or 0L depending on the compiler and the language. Sun's docs tells me this about Java's "null literal": The null type has one value, the null reference, represented by the literal null, which is formed from ASCII characters. A null literal is always of the null type. So this is all very nice. I know what a null pointer reference is, and thank you for the compiler notes. Now I'm a little fuzzy on the idea of a literal in Java so I read on... A literal is the source code representation of a fixed value; literals are represented directly in your code without requiring computation. There's also a special null literal that can be used as a value for any reference type. null may be assigned to any variable, except variables of primitive types. There's little you can do with a null value beyond testing for its presence. Therefore, null is often used in programs as a marker to indicate that some object is unavailable. Ok, so I think I get it now. In C++ NULL is a macro that, when compiled, defines the null pointer constant. In Java, null is a fixed value that any non-primitive can be assigned too; great for testing in a handy if statement. Java does not have pointers, so I can see why they kept null a simple value rather than anything fancy. But why did java decide to change the all caps NULL to null? Furthermore, am I missing anything here?

    Read the article

  • ON DELETE RESTRICT Causing Error 150

    - by Levi Hackwith
    CREATE TABLE project ( id INTEGER NOT NULL AUTO_INCREMENT, created_at DATETIME NOT NULL, name VARCHAR(75) NOT NULL, description LONGTEXT NOT NULL, is_active TINYINT NOT NULL DEFAULT '1', PRIMARY KEY (id), INDEX(name, created_at) ) ENGINE = INNODB; CREATE TABLE role ( id INTEGER NOT NULL, name VARCHAR(50) NOT NULL, description LONGTEXT NOT NULL, PRIMARY KEY (id) ) ENGINE = INNODB; CREATE TABLE organization ( id INTEGER NOT NULL AUTO_INCREMENT, created_at DATETIME NOT NULL, name VARCHAR(100) NOT NULL, is_active TINYINT NOT NULL DEFAULT '1', PRIMARY KEY (id) ) ENGINE = INNODB; CREATE TABLE user ( id INTEGER NOT NULL AUTO_INCREMENT, created_at DATETIME NOT NULL, role_id INTEGER NOT NULL, organization_id INTEGER NOT NULL, last_login_at DATETIME NOT NULL, last_ip_address VARCHAR(25) NOT NULL, username VARCHAR(45) NOT NULL, password CHAR(32) NOT NULL, email_address VARCHAR(255) NOT NULL, first_name VARCHAR(45) NOT NULL, last_name VARCHAR(45) NOT NULL, address_1 VARCHAR(100) NOT NULL, address_2 VARCHAR(25) NULL, city VARCHAR(25) NOT NULL, state CHAR(2) NOT NULL, zip_code VARCHAR(10) NOT NULL, primary_phone_number VARCHAR(10) NOT NULL, secondary_phone_number VARCHAR(10) NOT NULL, is_primary_organization_contact TINYINT NOT NULL DEFAULT '0', is_active TINYINT NOT NULL DEFAULT '1', PRIMARY KEY (id), CONSTRAINT fk_user_role_id FOREIGN KEY (role_id) REFERENCES role (id) ON UPDATE RESTRICT ON DELETE RESTRICT, CONSTRAINT fk_user_organization_id FOREIGN KEY (organization_id) REFERENCES organization (id) ON UPDATE RESTRICT ON DELETE RESTRICT ) ENGINE = INNODB; CREATE TABLE project_user ( user_id INTEGER NOT NULL, project_id INTEGER NOT NULL, PRIMARY KEY (user_id, project_id), CONSTRAINT fk_project_user_user_id FOREIGN KEY (user_id) REFERENCES user (id) ON UPDATE RESTRICT ON DELETE CASCADE, CONSTRAINT fk_project_user_project_id FOREIGN KEY (project_id) REFERENCES project (id) ON UPDATE RESTRICT ON DELETE RESTRICT ) ENGINE = INNODB; CREATE TABLE ticket_category ( id INTEGER NOT NULL AUTO_INCREMENT, name VARCHAR(20) NOT NULL, description LONGTEXT NOT NULL, PRIMARY KEY (id) ) ENGINE = INNODB; CREATE TABLE ticket_type ( id INTEGER NOT NULL AUTO_INCREMENT, name VARCHAR(20) NOT NULL, description LONGTEXT NOT NULL, PRIMARY KEY (id) ) ENGINE = INNODB; CREATE TABLE ticket_status ( id INTEGER NOT NULL AUTO_INCREMENT, name VARCHAR(20) NOT NULL, description LONGTEXT NOT NULL, PRIMARY KEY (id) ) ENGINE = INNODB; CREATE TABLE ticket ( id INTEGER NOT NULL AUTO_INCREMENT, created_at DATETIME NOT NULL, project_id INTEGER NOT NULL, created_by INTEGER NOT NULL, submitted_by INTEGER NOT NULL, assigned_to INTEGER NULL, category_id INTEGER NOT NULL, type_id INTEGER NOT NULL, title VARCHAR(75) NOT NULL, description LONGTEXT NOT NULL, contact_type_id TINYINT NOT NULL, affects_all_clients TINYINT NOT NULL DEFAULT '0', is_billable TINYINT NOT NULL DEFAULT '1', esimated_hours DECIMAL(4, 1) NOT NULL DEFAULT '0', hours_worked DECIMAL (4, 1) NOT NULL DEFAULT '0', status_id TINYINT NOT NULL, PRIMARY KEY (id), CONSTRAINT fk_ticket_project_id FOREIGN KEY (project_id) REFERENCES project (id) ON UPDATE RESTRICT ON DELETE RESTRICT, CONSTRAINT fk_ticket_created_by FOREIGN KEY (created_by) REFERENCES user (id) ON UPDATE RESTRICT ON DELETE RESTRICT, CONSTRAINT fk_ticket_submitted_by FOREIGN KEY (submitted_by) REFERENCES user (id) ON UPDATE RESTRICT ON DELETE RESTRICT, CONSTRAINT fk_ticket_assigned_to FOREIGN KEY (assigned_to) REFERENCES user (id) ON UPDATE RESTRICT ON DELETE RESTRICT, CONSTRAINT fk_ticket_category_id FOREIGN KEY (category_id) REFERENCES ticket_category (id) ON UPDATE RESTRICT ON DELETE RESTRICT, CONSTRAINT fk_ticket_type_id FOREIGN KEY (type_id) REFERENCES ticket_type (id) ON UPDATE RESTRICT ON DELETE RESTRICT, CONSTRAINT fk_ticket_status_id FOREIGN KEY (status_id) REFERENCES ticket_status (id) ON UPDATE RESTRICT ON DELETE RESTRICT ) ENGINE = INNODB; CREATE TABLE ticket_time_entry ( id INTEGER NOT NULL AUTO_INCREMENT, user_id INTEGER NOT NULL, ticket_id INTEGER NOT NULL, started_at DATETIME NOT NULL, ended_at DATETIME NOT NULL, PRIMARY KEY (id), CONSTRAINT fk_ticket_time_entry_user_id FOREIGN KEY (user_id) REFERENCES user (id) ON UPDATE RESTRICT ON DELETE RESTRICT, CONSTRAINT fk_ticket_time_entry_ticket_id FOREIGN KEY (ticket_id) REFERENCES ticket (id) ON UPDATE RESTRICT ON DELETE RESTRICT ) ENGINE = INNODB; The ticket table's create statement causes an error 150. I have no clue why. When I remove the ON DELETE RESTRICT statements from the table declaration, it works. Why is that?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >