Search Results

Search found 4593 results on 184 pages for 'operator equal'.

Page 33/184 | < Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >

  • What does "<<" mean in C#?

    - by Simon G
    Hi, Basically the questions in the title. I'm looking at the MVC 2 source code: public enum HttpVerbs { Get = 1 << 0, Post = 1 << 1, Put = 1 << 2, Delete = 1 << 3, Head = 1 << 4 } and I'm just curious as to what "<<" does. Thanks

    Read the article

  • using LIKE with logical operators

    - by ryanthegecko
    i can't seem to figure out how to combine LIKE with an OR or AND: DELETE * FROM persons WHERE FirstName = 'Abe' AND LastName LIKE '%coln'; Looks like it should owrk to me but I get error 1064 (syntax0 Is there a correct way to do this?

    Read the article

  • Implementing __concat__

    - by Casebash
    I tried to implement __concat__, but it didn't work >>> class lHolder(): ... def __init__(self,l): ... self.l=l ... def __concat__(self, l2): ... return self.l+l2 ... def __iter__(self): ... return self.l.__iter__() ... >>> lHolder([1])+[2] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for +: 'lHolder' and 'list' How can I fix this?

    Read the article

  • Should I use `!IsGood` or `IsGood == false`?

    - by chills42
    I keep seeing code that does checks like this if (IsGood == false) { DoSomething(); } or this if (IsGood == true) { DoSomething(); } I hate this syntax, and always use the following syntax. if (IsGood) { DoSomething(); } or if (!IsGood) { DoSomething(); } Is there any reason to use '== true' or '== false'? Is it a readability thing? Do people just not understand Boolean variables? Also, is there any performance difference between the two?

    Read the article

  • SQL searching table fields with LIKE

    - by Tom Gullen
    Given your data stored somewhere in a database: Hello my name is Tom I like dinosaurs to talk about SQL. SQL is amazing. I really like SQL. We want to implement a site search, allowing visitors to enter terms and return relating records. A user might search for: Dinosaurs And the SQL: WHERE articleBody LIKE '%Dinosaurs%' Copes fine with returning the correct set of records. How would we cope however, if a user mispells dinosaurs? IE: Dinosores (Poor sore dino). How can we search allowing for error in spelling? We can associate common misspellings we see in search with the correct spelling, and then search on the original terms + corrected term, but this is time consuming to maintain. Any way programatically?

    Read the article

  • Dictionary keys don't contain a key that's already contained in keys

    - by ran
    Why is the following 'exist' boolean variable getting a value of false??? foreach (Cell existCell in this.decoratorByCell.Keys) { //this call yield the same hashcode for both cells. still exist==false bool exist = this.decoratorByCell.ContainsKey(existCell); } I've overridden GetHashCode() & Equals() Methods as follows: public override int GetHashCode() { string nodePath = GetNodePath(); return nodePath.GetHashCode() + m_ownerColumn.GetHashCode(); } public bool Equals(Cell other) { bool nodesEqual = (other.OwnerNode == null && this.OwnerNode == null) || (other.GetNodePath() == this.GetNodePath()); bool columnsEqual = (other.OwnerColumn == null && this.OwnerColumn == null) || (other.OwnerColumn == this.OwnerColumn); bool treesEqual = (this.m_ownerTree == other.m_ownerTree); return (nodesEqual && columnsEqual && treesEqual); }

    Read the article

  • Linked List pop() function

    - by JKid314159
    Consider the following list: [LinkNode * head -- LinkNode * node1 -- LinkNode * node2] I'm creating a stack of FIFO. I Call pop() which I want to pop node1. LinkNode::LinkNode(int numIn) { this->numIn = numIn; next = null; } . . . int LinkNode::pop() { Link * temp = head->next; head = temp->next; int popped = head->nodeNum; delete temp; Return numOut; Question: 1) head should be a pointer or a LinkNode *? 2) Link * temp is created on the call stack and when pop finishes doesn't temp delete automatically? 3) My major confusion is on what is the value of temp-next? Does this point to node1.next which equals node2? Appreciate your help? My reference is C++ for Java Programmers by Weiss.

    Read the article

  • VB.NET overloading array access?

    - by Wayne Werner
    Hi, Is it possible to overload the array/dict access operators in VB.net? For example, you can state something like: Dim mydict As New Hashtable() mydict.add("Cool guy", "Overloading is dangerous!") mydict("Cool guy") = "Overloading is cool!" And that works just fine. But what I would like to do is be able to say: mydict("Cool guy") = "3" and then have 3 automagically converted to the Integer 3. I mean, sure I can have a private member mydict.coolguy and have setCoolguy() and getCoolguy() methods, but I would prefer to be able to write it the former way if at all possible. Thanks

    Read the article

  • Index, assignment and increment in one statement behaves differently in C++ and C#. Why?

    - by Ivan Zlatanov
    Why is this example of code behaving differently in c++ and C#. [C++ Example] int arr[2]; int index = 0; arr[index] = ++index; The result of which will be arr[1] = 1; [C# Example] int[] arr = new int[2]; int index = 0; arr[index] = ++index; The result of which will be arr[0] = 1; I find this very strange. Surely there must be some rationale for both languages to implement it differently? I wonder what would C++/CLI output?

    Read the article

  • Linq like or other construction

    - by Yauhen Kavalenka
    I have DB oracle in my solution. I want to have some results in this query. Query example: select * from doctor where doctor.name like '%IVANOV_A%'; But if i do it at LINQ i cannot get any result. from p in repository.Doctor.Where(x => x.Name.ToLower().Containsname)) select p; Where 'name' is variable of string parameter. Web layout request next string: "Ivanov a" or "A Ivanov" But i suggest for user choose you pattetn for query. How i can to get "patient by name" if name consist of "First name" and "Last name" but user doesn't know your doctor's full name?

    Read the article

  • MySQL: Which is faster — INSTR or LIKE?

    - by Grekker
    If your goal is to test if a string exists in a MySQL column (of type 'varchar', 'text', 'blob', etc) which of the following is faster / more efficient / better to use, and why? Or, is there some other method that tops either of these? INSTR( columnname, 'mystring' ) > 0 vs columnname LIKE '%mystring%'

    Read the article

  • c++ how to ? function_x ( new object1 )

    - by ismail marmoush
    Hi i want to do the next instead of MyClass object; function_x (object); i want to function_x ( new object ); so what will be the structure of the MyClass to be able to do that .. if i just compiled it , it gives me a compile time error answer function_x (MyClass() ) New Edit thanks for the quick answers.. i did ask the wrong Question i should have asked how temporary variables created in C++ and the answer

    Read the article

  • Optimize conditional operators branching in C#

    - by abatishchev
    Hello. I have next code: return this.AllowChooseAny.Value ? radioSpecific.Checked ? UserManager.CurrentUser.IsClient ? txtSubject.Text : subjectDropDownList.SelectedItem.Text : String.Empty : UserManager.CurrentUser.IsClient ? txtSubject.Text : subjectDropDownList.SelectedItem.Text; or in less complex form: return any ? specified ? isClient ? textbox : dropdown : empty : isClient ? textbox : dropdown; or in schematic form: | any / \ specified isClient / \ / \ isClient empty textbox dropdown / \ textbox dropdown Evidently I have a duplicated block on two different levels. Is it possible to optimize this code to probably split them to one? Or something like that..

    Read the article

  • C++ brain teaser

    - by mxp
    I recently refactored code like this (MyClass to MyClassR). class SomeMember { long m_value; public: SomeMember() : m_value(0) {} SomeMember(int a) : m_value(a) {} SomeMember(int a, int b) : m_value(a+b) {} }; class MyClass { SomeMember m_first, m_second, m_third; public: MyClass(const bool isUp, const int x, const int y) { if (isUp) { m_first = SomeMember(x); m_second = SomeMember(y); m_third = SomeMember(x, y); } else { m_first = SomeMember(y); m_second = SomeMember(x); m_third = SomeMember(y, x); } } }; class MyClassR { SomeMember m_first, m_second, m_third; public: MyClassR(const bool isUp, const int x, const int y) : m_first(isUp ? x : y) , m_second(isUp ? y : x) , m_third(isUp ? x, y : y, x) { } }; What is the error, why does it compile (at least VC6 with warning level 3 doesn't complain) and what is the right way of doing it? I (assume) I already have all these answers but I think it's and interesting problem to share.

    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

  • Can I customize the indentation of ternary operators in emacs' cperl-mode?

    - by Ryan Thompson
    In emacs cperl-mode, ternary operators are not treated specially. If you break them over multiple lines, cperl-mode simply indents each line the same way it indents any continued statement, like this: $result = ($foo == $bar) ? 'result1' : ($foo == $baz) ? 'result2' : ($foo == $qux) ? 'result3' : ($foo == $quux) ? 'result4' : fail_result; This is not very readable. Is there some way that I can convince cperl-mode indent like this? $result = ($foo == $bar) ? 'result1' : ($foo == $baz) ? 'result2' : ($foo == $qux) ? 'result3' : ($foo == $quux) ? 'result4' : fail_result; By the way, code example from this question.

    Read the article

  • printing using one '\n'

    - by Alex
    I am pretty sure all of you are familiar with the concept of the Big4, and I have several stuffs to do print in each of the constructor, assignment, destructor, and copy constructor. The restriction is this: I CAN'T use more than one newline (e.g., ƒn or std::endl) in any method I can have a method called print, so I am guessing print is where I will put that precious one and only '\n', my problem is that how can the method print which prints different things on each of the element I want to print in each of the Big4? Any idea? Maybe overloading the Big4?

    Read the article

  • Using __str__ representation for printing objects in containers in Python

    - by BobDobbs
    I've noticed that when an instance with an overloaded str method is passed to the print() function as an argument, it prints as intended. However, when passing a container that contains one of those instances to print(), it uses the repr method instead. That is to say, print(x) displays the correct string representation of x, and print(x, y) works correctly, but print([x]) or print((x, y)) prints the repr representation instead. First off, why does this happen? Secondly, is there a way to correct that behavior of print() in this circumstance?

    Read the article

  • Dynamic Like Statement in SQL

    - by Peter McElhinney
    Hey there! I've been racking my brain on how to do this for a while, and i know that some genius on this site will have the answer. Basically i'm trying to do this: SELECT column FROM table WHERE [table][column] LIKE string1 OR [table][column] LIKE string2 OR [table][column] LIKE string3... for a list of search strings stored in a column of a table. Obviously I can't do a like statement for each string by hand because i want the table to be dynamic. Any suggestions would be great. :D EDIT: I'm using MSSQL :(

    Read the article

  • CSS "and" and "or"

    - by Misiur
    Hi there. I've got quite big trouble, because i need to anathematise from styling some input types. I had something like: .registration_form_right input:not([type="radio") { //Nah. } But i don't want to style checkboxes too. I've tried: .registration_form_right input:not([type="radio" && type="checkbox"]) .registration_form_right input:not([type="radio" && "checkbox"]) .registration_form_right input:not([type="radio") && .registration_form_right input:not(type="checkbox"]) How to use &&? And I'll need to use || soon, and I think that usage will be same. Thanks.

    Read the article

< Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >