What are the most important functional differences between C# and VB.NET?

The linked comparisons are very thorough, but as far as the main differences I would note the following: C# has anonymous methodsVB has these now, too C# has the yield keyword (iterator blocks)VB11 added this VB supports implicit late binding (C# has explicit late binding now via the dynamic keyword) VB supports XML literals VB … Read more

Comparing ruby hashes [duplicate]

here is a slightly modified version from colin’s. class Hash def diff(other) (self.keys + other.keys).uniq.inject({}) do |memo, key| unless self[key] == other[key] if self[key].kind_of?(Hash) && other[key].kind_of?(Hash) memo[key] = self[key].diff(other[key]) else memo[key] = [self[key], other[key]] end end memo end end end It recurses into the hashes for more efficient left and right {a: {c: 1, b: … Read more

DateTime Comparison Precision

What about using a timespan. if (Math.Truncate((A – B).TotalMinutes) == 0) { //There is less than one minute between them } Probably not the most elegant way, but it allows for cases which are one second apart and yet have different days/hours/minutes parts such as going over midnight. Edit: it occured to me that the … Read more

java Long datatype comparison

Long is an object, not a primitive. By using == you’re comparing the reference values. You need to do: if(str.equals(str2)) As you do in your second comparison. Edit: I get it … you are thinking that other objects act like String literals. They don’t*. And even then, you never want to use == with String … Read more

Understanding cmp instruction

cmp arg2, arg1 performs the same operation as sub arg2, arg1 except that none of the operands are modified. The difference is not stored anywhere. However, the flags register is updated and can be used in a conditional jump, like jump-if-equal (JE), most often as the next instruction after the cmp. The advantage over other … Read more

Why does == equality comparison between arrays not work?

if (iar1 == iar2) Here iar1 and iar2 are decaying to pointers to the first elements of the respective arrays. Since they are two distinct arrays, the pointer values are, of course, different and your comparison tests not equal. To do an element-wise comparison, you must either write a loop; or use std::array instead std::array<int, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)