Strange? C# made easy with java
-
Witness the following C# piece of code:
var x = 0;
x = x++;What does this even means? How could x be equal to x++? It's obviously different! Well now imagine the following Java code
int x = 0;
x = x++;Now imagine the C# is, in fact, doing the same thing! Bazongas! The value of
x
is so obvious now! Obviously 1 or 0! :-oA new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
The equivalent of that code in C# would also be using an "int". Exactly like below;
int x = 0;
x = x++;..which IS your java-example. The "var" keyword is not meant to be used as a replacement for int, and anyone doing so should stop coding. It clearly has a joke icon.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)
-
Seriously. Somethings in C# seems more understandable to me with java example. But... I am not that Java guy.
Dgmarious wrote:
But... I am not that Java guy.
That's good. Most of the Java guys I met were fanatics, as if the language had been invented as part of a clever plan by Scientology.
I am endeavoring, ma'am, to construct a mnemonic memory circuit using stone knives and bearskins.
-
Perhaps it is because you don't know how to program in C#?
hmmm. maybe though. But I guess I have some level of proficiency in C# and have being doing some real complex stuffs... But for once I came across need for Data-flow (Producer consumer pattern with BlockingCollection) I found an example of BlockingQueue in java very handy and translate to c#.
-
Seriously. Somethings in C# seems more understandable to me with java example. But... I am not that Java guy.
Essentially, if you know Java, then you're basically familiar with C#. Even a lot of the class names are the same.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
Dgmarious wrote:
But... I am not that Java guy.
That's good. Most of the Java guys I met were fanatics, as if the language had been invented as part of a clever plan by Scientology.
I am endeavoring, ma'am, to construct a mnemonic memory circuit using stone knives and bearskins.
CodeWraith wrote:
Most of the Java guys I met were fanatics
I encountered that 25 years ago. Gads, is it still true today, or did they all become Ruby fanatics? ;)
Latest Article - Class-less Coding - Minimalist C# and Why F# and Function Programming Has Some Advantages Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
Seriously. Somethings in C# seems more understandable to me with java example. But... I am not that Java guy.
As your other post eluded to, yeah, Java loves its patterns, and sometimes there's a gem in some Java example. On the other hand, the reason Java loves its patterns so much is that doing complex things in Java is so much more of a PITA.
Latest Article - Class-less Coding - Minimalist C# and Why F# and Function Programming Has Some Advantages Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
CodeWraith wrote:
Most of the Java guys I met were fanatics
I encountered that 25 years ago. Gads, is it still true today, or did they all become Ruby fanatics? ;)
Latest Article - Class-less Coding - Minimalist C# and Why F# and Function Programming Has Some Advantages Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
At least those that tried to assimilate me about four years ago still were.
I am endeavoring, ma'am, to construct a mnemonic memory circuit using stone knives and bearskins.
-
hmmm. maybe though. But I guess I have some level of proficiency in C# and have being doing some real complex stuffs... But for once I came across need for Data-flow (Producer consumer pattern with BlockingCollection) I found an example of BlockingQueue in java very handy and translate to c#.
Have a look at the [TPL Dataflow](https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/dataflow-task-parallel-library) library. It's stupid easy and does the job nicely without needing any of that mungy blocking.
"There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli
-
Witness the following C# piece of code:
var x = 0;
x = x++;What does this even means? How could x be equal to x++? It's obviously different! Well now imagine the following Java code
int x = 0;
x = x++;Now imagine the C# is, in fact, doing the same thing! Bazongas! The value of
x
is so obvious now! Obviously 1 or 0! :-oA new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
Super Lloyd wrote:
int x = 0; x = x++;
I knew that this was going to result in x being 1, so to confirm I tested it and yes as I knew it results in x being 0. It's a nasty little b*gger that one and I hope I never come across it in code.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
-
Essentially, if you know Java, then you're basically familiar with C#. Even a lot of the class names are the same.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013 -
Super Lloyd wrote:
int x = 0; x = x++;
I knew that this was going to result in x being 1, so to confirm I tested it and yes as I knew it results in x being 0. It's a nasty little b*gger that one and I hope I never come across it in code.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
GuyThiebaut wrote:
It's a nasty little b*gger that one and I hope I never come across it in code.
I dunno, seen a few juniors doing just that, also other juniors that told them to stop as it might cause an endless loop. :sigh: When that comes out it's time for a coffee - away from the office.
Format Succe&*(gD@@@:beer:@@@@@@*@x@@
-
GuyThiebaut wrote:
It's a nasty little b*gger that one and I hope I never come across it in code.
I dunno, seen a few juniors doing just that, also other juniors that told them to stop as it might cause an endless loop. :sigh: When that comes out it's time for a coffee - away from the office.
Format Succe&*(gD@@@:beer:@@@@@@*@x@@
-
harold aptroot wrote:
Confiscate their coding licenses
You are much too lenient. That sort of blunder calls for staking out on an anthill, at the very least! :mad:
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack. --Winston Churchill
-
harold aptroot wrote:
Confiscate their coding licenses
You are much too lenient. That sort of blunder calls for staking out on an anthill, at the very least! :mad:
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack. --Winston Churchill
Time to call the RSPCA
Wrong is evil and must be defeated. - Jeff Ello
-
Time to call the RSPCA
Wrong is evil and must be defeated. - Jeff Ello
Jörgen Andersson wrote:
RSPCA
The Royal Society for the Prevention of Cruelty to Ants? :)
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack. --Winston Churchill