|
Cuntpunch posted:
Someone who didn't know that strings have null as their default value wrote this ten years ago and then it cargoculted from there. Also, I'm new to C# and serious coding so I'm really looking forward to see my code in here very soon.
|
# ¿ Feb 23, 2019 12:29 |
|
|
# ¿ May 12, 2024 09:08 |
|
Aren't Lists internally implemented as dynamic arrays in .NET? Why do I see people converting them to static arrays? What's the advantage?
|
# ¿ Mar 6, 2019 00:13 |
|
qsvui posted:
this is really good code, but I made a small improvement to make it more flexible
|
# ¿ Mar 6, 2019 18:19 |
|
Saw this gem todaycode:
|
# ¿ May 14, 2019 21:18 |
|
Volguus posted:Personally I believe that Empty() would read better than Any, but that's neither here or there. Checking for "Count <= 0", especially when said Count returns a signed value just screams of defensive programming. You never know when the value could potentially overflow, when a bug in that list implementation may return -1, when radiation from the sun will flip a bit. Since I have a hard time believing that "== 0" is more efficient than "<= 0" I would almost always prefer the "<= 0" if something like "Empty" is not available. I asked about it and apparently it's what happens when you use some ReSharper auto refactoring functionality. It inverts a ">0" statement, but isn't smart enough to know that arrays can't have a negative size. Also, gotta agree that if the fabric of space and time broke down and System.Collections started producing negative sized arrays I would want my program to drop everything and tell me ASAP.
|
# ¿ May 15, 2019 20:03 |
|
Linear Zoetrope posted:Out of wonder, which languages? The only one I know of is C strings, I wasn't aware that some (modern) languages didn't just keep an associated count variable. LINQ extends everything enumerable with a Count() method. Mixing up list.Count and list.Count() can have huge performance implications in C#.
|
# ¿ May 15, 2019 23:12 |
|
Hi badidea, you can just type -75000 or if you REALLY want to specify a range for some reason you can also type -65000.00057. As it's currently working and usable, it's not a high priority fix for now. We did put it on our to-do list though!
|
# ¿ Jul 1, 2022 10:20 |
|
CPColin posted:Yeah, I've seen if (map.contains(key)) { return map.get(key) } else { return null } plenty of times too I'm not a coding horror perpetrator, BUT ... IIRC the .NET hashmap actually throws an exception when a key is not present. So for someone coming from that neck of the woods that would be good code. There is a TryGet method too, so you don't actually have to write the above every time. But I don't know how long it's been there
|
# ¿ Dec 9, 2023 18:01 |
|
raminasi posted:I just looked this up because I was curious and it was introduced in .NET Framework 2.0, which was 2005. That's when they introduced generics, so I guess it has always been there. Now that I think about it, their approach to throwing an exception in case of a missing keys actually makes a lot of sense. For value types anything a GetKey method could return for a missing key could be confused for an actual value, i.e. am I getting back a 0 because the inventory for this productID is 0 or because the productID is not in the hashmap at all?
|
# ¿ Dec 11, 2023 02:22 |
|
Htbh, but I would not approve this in a pull request because it clearly doesn't work if you pass a 0(which is even). AI still has a long way to go before it can replace a real developer
|
# ¿ Mar 7, 2024 15:24 |
|
leper khan posted:or any negative numbers, despite signed input I think there is a very clever solution for this that could save a lot of work code:
|
# ¿ Mar 7, 2024 17:12 |
|
Qwertycoatl posted:I have literally seen I love this so much, especially because it doesn't even work if you execute it on a German Windows So here is the correct version that is actually safe to deploy internationally code:
|
# ¿ Mar 7, 2024 22:04 |
|
leper khan posted:fail PR. use "." and the invariant cultureinfo whoa, buddy, what kind of thread do you think this is? We don't look kindly on that kind of code in here
|
# ¿ Mar 7, 2024 22:29 |
|
Jen heir rick posted:You can also set the current culture to en-us: Totally agree. Just think of all the types of exciting heisenbugs you can generate when one or two out of 30+ threads in the System.Threading thread pool suddenly have a different culture from the rest(but only occasionally, because of the random life time of a pool thread of anything between milliseconds and forever). It could drive developers insane for months trying to diagnose this
|
# ¿ Mar 8, 2024 10:25 |
|
QuarkJets posted:
This good solid code, but personally I would go with a more modern functional programming approach Python code:
|
# ¿ Mar 11, 2024 10:34 |
|
|
# ¿ May 12, 2024 09:08 |
|
Bruegels Fuckbooks posted:I thought about it a bit and I think we can use tensorflow for this application. This may or may not work depending upon your CPU type and CUDA version present on your system - when you generate the model, it's important to take a vm of your working environment so you can ensure consistent results. lmao It should throw an UnsafeNumberContentDetected exception if you pass "80085" to it. Children might be using it
|
# ¿ Mar 11, 2024 17:01 |