What does '^' do in c# (Enums)?
I was reading some 3rd party code and I found this: x.Flags = x.Flags ^ Flags.Hidden; What does it do? I've used '&' and '|' for bitwise 'and' and 'or' with enums, but it's the first time I see the that symbol... ...
I was reading some 3rd party code and I found this: x.Flags = x.Flags ^ Flags.Hidden; What does it do? I've used '&' and '|' for bitwise 'and' and 'or' with enums, but it's the first time I see the that symbol... ...
can someone explain this one to me? a link to something in the php manual even?? i can't find anything: if ($_SERVER['SERVER_PORT'] <> 443) { doSomething(); } ...
Is there some way I can define String[int] to avoid using String.CharAt(int)? ...
I understand that using the "===" compares type, so running the following code results in "not equal" because it's comparing a number type to a string type. var a = 20; var b = "20"; if (a === b) { alert("They are equal"); } else { alert("They are not equal"); } But I dont understand how using the "==" to compa...
In Python, if I do this: print "4" * 4 I get > "4444" In Perl, I'd get > 16 Is there an easy way to do the former in Perl? ...
DataGridView, for example, lets you do this: DataGridView dgv = ...; DataGridViewCell cell = dgv[1,5]; but for the life of me I can't find the documentation on the index/square-bracket operator. What do they call it? Where is it implemented? Can it throw? How can I do the same thing in my own classes? ETA: Thanks for all the quic...
I'm talking about this: If we have the letter 'A' which is 77 in decimal and 4D in Hex. I am looking for the fastest way to get D. I thought about two ways: Given x is a byte. x << 4; x >> 4 x %= 16 Any other ways? Which one is faster? Thanks. ...
I faced a little trouble - I do not know if I can define my own operators for my classes. For example: type TMinMatrix = class(TMatrix) private RowAmount: Byte; ColAmount: Byte; Data: DataMatrix; DemVector, SupVector: SupplyDemand; public constructor Create(Rows, Cols: Byte); function GetRow...
Why is ++i is l-value? and i++ not Initially there were 2 questions one was removed since that was exact duplicate. So don't down vote the answers that were answering difference between pre- and post-increment. ...
I this post, I've seen this: class MonitorObjectString: public MonitorObject { // some other declarations friend inline bool operator==(/*const*/ MonitorObjectString& lhs, /*const*/ MonitorObjectString& rhs) { return lhs.fVal==rhs.fVal; } } Before we can continue, THIS IS VERY IMPORTANT:...
Forgive me, for I am fairly new to C++, but I am having some trouble regarding operator ambiguity. I think it is compiler-specific, for the code compiled on my desktop. However, it fails to compile on my laptop. I think I know what's going wrong, but I don't see an elegant way around it. Please let me know if I am making an obvious mista...
JavaScript does funky automatic conversions with objects: var o = {toString: function() {return "40"; }}; print(o + o); print((o+1)+o); print((o*2) + (+o)); will print: 4040 40140 120 This is because +, if any of the arguments are objects/strings, will try to convert all the arguments to strings then concatenate them. If all argume...
According to the documentation of the == operator in MSDN, For predefined value types, the equality operator (==) returns true if the values of its operands are equal, false otherwise. For reference types other than string, == returns true if its two operands refer to the same object. For the string type, == compares t...
I was under the impression that Python had a ternary operator... But then I did some research, Not enough to find out for sure though Thought I'd ask the professionals ;) ...
From what I'm reading, $ is described as "applies a function to its arguments." However, it doesn't seem to work quite like (apply ...) in Lisp, because it's a binary operator, so really the only thing it looks like it does is help to avoid parentheses sometimes, like foo $ bar quux instead of foo (bar quux). Am I understanding it right?...
I have this If condition in VB6 If ( X AND ( 2 ^ Y)) Then a = a + " 1" Else a = a + " 0" I want the same equivalent in C# I tried doing like if ( X && ( 2 ^ Y)) // ERROR: && can not be used between int to int a = a + "1"; else a = a + "0"; but this thing is giving me an error. Here is my complete VB code that I wan...
Is there a VB.NET equivalent for C#'s ?? operator? ...
I'm interested in implementing a Forth system, just so I can get some experience building a simple VM and runtime. When starting in Forth, one typically learns about the stack and its operators (DROP, DUP, SWAP, etc.) first, so it's natural to think of these as being among the primitive operators. But they're not. Each of them can be br...
Found the following in an Oracle-based application that we're migrating (generalized): SELECT Table1.Category1, Table1.Category2, count(*) as Total, count(Tab2.Stat) AS Stat FROM Table1, Table2 WHERE (Table1.PrimaryKey = Table2.ForeignKey(+)) GROUP BY Table1.Category1, Table1.Category2 What does (+) do in a WHERE claus...
A while ago, I asked a question about $, and got useful answers -- in fact, I thought I understood how to use it. It seems I was wrong :( This example shows up in a tutorial: instance Monad [] where xs >>= f = concat . map f $ xs I can't for the life of me see why $ was used there; ghci isn't helping me either, as even tests I do...