tagged [comparison]

How to check if the string is empty?

How to check if the string is empty? Does Python have something like an empty string variable where you can do: Regardless, what's the most elegant way to check for empty string values? I find hard co...

Detecting negative numbers

Detecting negative numbers I was wondering if there is any way to detect if a number is negative in PHP? I have the following code: I need to find out if `$profitloss` is negative and if it is, I need...

26 Sep at 20:26

Compare two lists to search common items

Compare two lists to search common items How to get all elements from one list that are present also in second list? In this case should be: 1, 4 I talk of course about method without foreach. Rather ...

31 Jul at 12:24

Comparing arrays for equality in C++

Comparing arrays for equality in C++ Can someone please explain to me why the output from the following code is saying that arrays are ? ``` int main() { int iar1[] = {1,2,3,4,5}; int iar2[] = {1,...

19 Apr at 23:11

Complex "Contains" string comparison

Complex "Contains" string comparison I'm developing a C# 4.5 app and I need a function to return true for the following comparison: > "bla LéOnAr d/o bla".ComplexContains("leonardo") In other words, I...

3 Mar at 01:13

Multiple Date range comparison for overlap: how to do it efficiently?

Multiple Date range comparison for overlap: how to do it efficiently? To check for overlap in two different dateranges, `{Start1, End1}` and `{Start2, End2}` I am checking: The question is, . If I hav...

Checking the equality of two slices

Checking the equality of two slices How can I check if two slices are equal, given that the operators `==` and `!=` are not an option? This does not compile with: > invalid operation: s1 == s2 (slice ...

14 Jul at 09:20

How do I do a case-insensitive string comparison?

How do I do a case-insensitive string comparison? How can I compare strings in a case insensitive way in Python? I would like to encapsulate comparison of a regular strings to a repository string, usi...

18 Jun at 22:29

Using InvariantCultureIgnoreCase instead of ToUpper for case-insensitive string comparisons

Using InvariantCultureIgnoreCase instead of ToUpper for case-insensitive string comparisons [this page](http://www.inq.me/post/ASPNet-MVC-Extension-method-to-create-a-Security-Aware-HtmlActionLink.asp...

What is difference between different string compare methods

What is difference between different string compare methods > [Differences in string compare methods in C#](https://stackoverflow.com/questions/44288/differences-in-string-compare-methods-in-c) In ....

23 May at 10:31

What's the prettiest way to compare one value against multiple values?

What's the prettiest way to compare one value against multiple values? Whats the way to compare one value against multiples options? I know there are loads of ways of doing this, but I'm looking for t...

31 Jan at 21:50

Python None comparison: should I use "is" or ==?

Python None comparison: should I use "is" or ==? My editor warns me when I compare `my_var == None`, but no warning when I use `my_var is None`. I did a test in the Python shell and determined both a...

25 Apr at 18:10

FluentAssertions: ShouldBeEquivalentTo vs Should().Be() vs Should().BeEquivalentTo()?

FluentAssertions: ShouldBeEquivalentTo vs Should().Be() vs Should().BeEquivalentTo()? Can anybody summarize differences and usage scope between them? I read SO articles, - [ShouldBeEquivalientTo()](ht...

23 May at 12:32

Why datetime cannot compare?

Why datetime cannot compare? my C# unit test has the following statement: Why it is failed with following information: Are they not the same? Use this if you only care to second: `Assert.AreEqual(logo...

14 Oct at 17:47

Is there a standard function to check for null, undefined, or blank variables in JavaScript?

Is there a standard function to check for null, undefined, or blank variables in JavaScript? Is there a universal JavaScript function that checks that a variable has a value and ensures that it's not ...

11 May at 09:13

Most performant way of checking empty strings in C#

Most performant way of checking empty strings in C# What is the best way for strings (I'm not [asking about initializing!](https://stackoverflow.com/questions/263191/in-c-should-i-use-string-empty-or-...

24 May at 03:27

How do you compare two version Strings in Java?

How do you compare two version Strings in Java? Is there a standard idiom for comparing version numbers? I can't just use a straight String compareTo because I don't know yet what the maximum number o...

13 Oct at 21:16

Java and C#, how close are they?

Java and C#, how close are they? I've been using C/C++ and Python, but I now I see that a lot of new programming books use Java or C# as examples. I don't think I'll use Java or C# for the time being,...

11 Nov at 14:55

Comparing two List<string> for equality

Comparing two List for equality Other than stepping through the elements one by one, how do I compare two lists of strings for equality (in .NET 3.0): This fails: ``` // Expected result. List expect...

C# generics compared to C++ templates

C# generics compared to C++ templates > [What are the differences between Generics in C# and Java… and Templates in C++?](https://stackoverflow.com/questions/31693/what-are-the-differences-between-ge...

23 May at 11:46

Difference between | and || or & and && for comparison

Difference between | and || or & and && for comparison > [A clear, layman’s explanation of the difference between | and || in c# ?](https://stackoverflow.com/questions/684648/a-clear-laymans-explanat...

23 May at 11:54

How to use StringComparison for strings in C#?

How to use StringComparison for strings in C#? I get a `string does not contain a definition for Contains` message when I do the above. What am I doing wrong here? Thanks in advance everyone! I am try...

28 Jul at 14:19

When to use CouchDB over MongoDB and vice versa

When to use CouchDB over MongoDB and vice versa I am stuck between these two NoSQL databases. In my project, I will be creating a database within a database. For example, I need a solution to create d...

Why does >= return false when == returns true for null values?

Why does >= return false when == returns true for null values? I have two variables of type int? (or Nullable if you will). I wanted to do a greater-than-or-equal (>=) comparison on the two variables ...

9 Dec at 16:36

How to compare two JSON objects with the same elements in a different order equal?

How to compare two JSON objects with the same elements in a different order equal? How can I test whether two JSON objects are equal in python, disregarding the order of lists? For example ... JSON do...

24 Jan at 21:31