The Right Way to Write if Statements in C#
9:04
Lists Are 3 Times SLOWER in .NET 9!
7:17
14 сағат бұрын
"Stop Using LINQ in .NET!"
9:15
Күн бұрын
I messed up. I'm sorry.
7:18
Ай бұрын
Make Your LINQ Up to 10x Faster!
11:08
Why Developers Already Hate .NET 9
10:12
The Pattern You MUST Learn in .NET
20:48
Пікірлер
@Ben-nc9qw
@Ben-nc9qw 2 сағат бұрын
en.wikipedia.org/wiki/Indentation_style#Allman_style
@Ben-nc9qw
@Ben-nc9qw 2 сағат бұрын
getting to the nuts and bolts of the c# issues now 😀
@andrewbennett5733
@andrewbennett5733 2 сағат бұрын
I learned software with C#/.NET, then immediately ended up in a Java/Spring job for two years. I'm now getting ready to start a new job that uses C#/.NET in a few weeks and your videos are really helping me remember all the things I've forgotten as well as REALLY learning the things I skipped over the first time! Thanks for taking the time to make such great educational content!
@KalleBlixtHagholm
@KalleBlixtHagholm 3 сағат бұрын
We use the one-liner when it's a simple check and return early in the method, e.g "if (foo == null) return false;". Otherwise always braces on new line.
@kakkarot1000
@kakkarot1000 3 сағат бұрын
The "^" operator is called a "Caret" in some countries.
@rnavedojr
@rnavedojr 3 сағат бұрын
MS is great, money is what they suck 😂
@Krshk999
@Krshk999 4 сағат бұрын
90% of those words were new to me and I'm on the way to becoming a senior
@paulpach
@paulpach 4 сағат бұрын
5:20 java was not open source from the beginning. Java 1.0 was released in 1995 and was not open sourced until 2006.
@ericlangedijk2585
@ericlangedijk2585 5 сағат бұрын
Funny that the braces war is still there in different languages. I can't read code where braces are at the end of the line. It looks asymmetrical in my eyes. Scope is much more difficult to see (for me). Sometimes I prefer oneliners, but only if a lot of comparable lines are following eachother. I also think code can be "personally aligned" in a team project. I like individuality.
@BackwardsDaveTV
@BackwardsDaveTV 5 сағат бұрын
All if statements can be written with curly braces but only if statements with one line in the body can be written without. For consistency just always use curly braces. And C# is not Java or JavaScript so put the curly braces on new lines for goodness sake.
@yupii1997
@yupii1997 6 сағат бұрын
To me this seems like a developer at microsoft needed this for a very very specific case, thus the reason it exists
@udavster
@udavster 6 сағат бұрын
What's wrong with validation using custom attributes on API?
@Looooooka
@Looooooka 7 сағат бұрын
Saves 2 mb on SQL database. Creates an index that takes 50 times more space :D
@ahmedfox5935
@ahmedfox5935 7 сағат бұрын
I used #1, and still using it.. After the video, I'll still be using it.. More convenient for me and more tidy, less lines, better readability..
@TheJamesboink
@TheJamesboink 8 сағат бұрын
I'm not sure if its actually testable in C#. It's already a "slower" language than C++ and in "Clean Code Horrible Performance" you can see how much of an ACTUAL impact clean code standards have on performance.
@WDGKuurama
@WDGKuurama 9 сағат бұрын
Hi nick. Do you have any videos explaining the new TypedResult from .Net 7? Results<TResult1,TResultN> I can't find anything covering it. I actually noticed it on the microsoft doc today and i wonder what are the full use cases for it. And how it can be used compared to what we had. And if it's limited to controllers only. It would be great to have your insight on this. Thanks.
@DickBakerSql
@DickBakerSql 9 сағат бұрын
from offset=6:03 you still need to try..catch the "await finishedTask" rather than assume a success completion (and beware AggregateException complexity as ever). STOP PRESS covered by OP below.
@F1nalspace
@F1nalspace 9 сағат бұрын
How to heck is this working, without no length specified in the array? Is the length automatically determined by the number of elements or by the actual indices? Don't get me wrong, i love index initializer for arrays and was waiting for it for so long (game/simulation dev) - but i don't see any use-case for this hat operator thingy. Why would i define something at the end? If i have an array for example that initializes a set of CPU instructions, the length of that instructions is finite - so i define the length beforehand and then map the instructions to the op-code index. Also one thing this bugs me a lot is the "Index" behind the scenes - which is also true for span. We work with many millions of data points, due to a high sample frequency and long time length. Right now, int-32 is sufficient, but we are already close to the limits of it. In the near future we really need a Span64 and Index64 or something like that, so we can use 64-bit indices and lengths directy - without the need to partition it.
@davidrizzo8765
@davidrizzo8765 11 сағат бұрын
Let me tell how often I use arrays like this..............um, I don't! I use Lists and fill them with Linq.
@omegabit
@omegabit 15 сағат бұрын
1) Most startups are populated by younger developers that are simply unaware that the new "hotness" is a convoluted mess for solving problems springing from the inadequacy of their fad tool that mainstream languages solved a long time ago in a technically superior way. Python for example, is popular in academia (and therefore among inexperienced devs) that have never actually constructed a sophisticated, enterprise scale app. (If you don't understand why a dynamically typed language sucks at scale, you have no business judging a strictly typed language.) 2) Most enterprise language developers are steeped in a particular employer's culture and have no concept of just how advanced and more capable C# is for LOB application development than languages like Java, C++, etc. (This includes C# devs that are shocked when they discover just how backwards Java is). Just look at Generics, (used vigorously in C# and Swift, but are utterly crippled in languages like Java and TypeScript. LINQ is a technology that is extremely important for C#, and it has no comparable feature in Java or any other popular language. This is why C#'s implementation of ORMs, Mocking and Serialization are vastly simpler and more capable than those written in competitor languages. C#'s handling of asynchronous programming via syntax was so good it was shamelessly stolen for Javascript (which couldn't steal its parallel processing syntax because it's single threaded, LOL. In fairness, C# shamelessly stole Swift's nullability operators and conventions, and both C# and the dotnet platform do advance at a breakneck pace, often by duplicating innovations that were invented in other language and even whole paradymes (like Functional Programming). Lastly, C# will run circles in terms of performance around any interpreted language, and the piss poor tooling of C++ makes it a poor candidate for developing sophisticated systems at scale. Unless you are working on some cutting edge engine in which every millimeter of performance is required, (and you have boatloads of money solving stupid problems that never arise in a garbage collected language with outstanding Run Time reflection, you might as well argue that you should develop in Assembly. 3) Simple ignorance of how much MS has embraced OSS. If you think you should use Visual Studio to develop C#, you have no business writing in C#. (VSCode have been the preferred tool for the better part of a decade, and it is a completely OSS Electron App.) .Net Core is completely open source and readily cross platform. It's default webserver, the inprocess Kestrel, is written on the same non-blocking C library that underpins node, and it's multithreaded. As for Windows, show me the Mac that can run native Linux within its kernel. Show me a non-hypervisor Virtualization technology on either Mac or Linux that comes close to the performance of HyperV. The last 2 major system vulnerabilities that required billions in mitigation were HeartBleed (OpenSSL), Log4J (Java), and now there is a somewhat improbably exploit in OpenSSH. MS customers didn't have to worry about the first two if they ran MS stacks. Saying MS is somehow bad while ignoring Google and Apple's business models is just clueless.
@BBOYLEENON
@BBOYLEENON 16 сағат бұрын
I'm sorry bro, but your English is terrible, you have a very strong accent and a cannot understand you without using subtitles.
@martinrasmussen6634
@martinrasmussen6634 16 сағат бұрын
First language I learned, was c/c++, and there was the syntax: If(true) { } So, when I code alone, in a project noone has to take over, it will be with this style. I find this the right mix of declaring scope, while maintaing easy oversight. However, any code that is done where others could need to read or change the code, I will always stick to this type: If (true) { } Reason is simple, it's about consistency, and having code look alike, and be easely read by all. There is so many other 'fights', I rather take, than this one..
@oquendo987
@oquendo987 17 сағат бұрын
is it possible to build it with cookies instead of bearer tokens?
@johncarew1130
@johncarew1130 18 сағат бұрын
Pretty sure that's known as a caret character, and not hat character.
@mindstyler
@mindstyler 10 сағат бұрын
Is widely known as the hat character
@dzllz
@dzllz 18 сағат бұрын
Clickbait, this seems useless, would have been interesting if you show what it’s good for
@ZamesC
@ZamesC 18 сағат бұрын
My feelings: #1 (two lines, no braces) I usually use this. #2 (one line, no braces) I will occasionally use this, often when there will be a series of one-liner if()s in a row. #3 (Opening brace on same line as if()) NEVER EVER EVER!!! #4 (opening brace on own line, aligned with the closing brace) Occasionally, often when I'm expecting to add more to the if() body) I am convinced that #3 is used by people who deliberately want to make their code unreadable. It goes back to UNIX developers ("This is a black art; not for merely mortals to understand!").
@keyser456
@keyser456 18 сағат бұрын
I've used it for doing simple parsing of multi-word commands input from the user in a game I'm working on: var splitAskTarget = fixedTarget.Split(' '); //excluding some validation to make sure >= 2 words string potentialAskTopic = splitAskTarget[^1]; // (single word topics only for now, last word) string shorterFixedTarget = string.Join(' ', splitAskTarget[..^2]); //start to 2nd to last word It's not pretty but no solution for something like this would be. It's niche, and I hate we're interchanging 0-based with 1-based in the same context of arrays, but it can save some keystrokes.
@EdKolis
@EdKolis 20 сағат бұрын
Now that I've been using Android Studio at work for a while, this UI actually looks not unfamiliar to me. I need to get a copy of Rider for my C# projects!
@alfflasymphonyx
@alfflasymphonyx 20 сағат бұрын
This is utterly useless feature. in addition, why use ^1 to indicate the last iitem in the array when we use 0 from the start. Two different way of indexing depending on where we start. Why? This is complete garbage!
@arturitodotnet
@arturitodotnet 20 сағат бұрын
Option #3 - Egyptian brackets. Option #4 - Hadouken brackets. Hadouken all the way. It's just easier to read.
@KingOfBlades27
@KingOfBlades27 22 сағат бұрын
Was thinking the exact same you mentioned: not a lot of use for me, but those who work "lower" definitely might be more excited about this.
@cronintechnology9901
@cronintechnology9901 22 сағат бұрын
Just chipping in here to mention yet another option. In the past I worked in teams where it was OK to do a single line return, but only if you added braces: if (success) { return true; } It's an old-skool defensive programming technique that saves you from the risk of someone later adding code without realising which scope it's in. I like this style, but only if you end up with a really succinct line of code and not a long sprawling one. Wasting vertical space is bad; it adds to your cognitive load. I actually dislike the Microsoft style with a line for every brace character, but "you can't fight city hall", and on most projects I end up sticking strictly to it. For a short, clear one line exit, I'm happy with it if my team is happy.
@theodorezographos4347
@theodorezographos4347 22 сағат бұрын
Why a compiler flag doesn't exist already to take care of this?
@JackBauerDev
@JackBauerDev 22 сағат бұрын
Lol a video for this
@davidpine7
@davidpine7 23 сағат бұрын
Random array of numbers... [ 6, 9, 4, 20 ]. 🤣
@salemmaglic
@salemmaglic 23 сағат бұрын
return success: :D
@kirillzlobin7135
@kirillzlobin7135 Күн бұрын
So many stuff to do to make just one api call in C#... Lots of videos showing different 20 line examples on how to do a get call. JS is a ninja
@rGunti
@rGunti Күн бұрын
Not knowing this operator from Python, I somehow find it more confusing that they opted for `^` instead of accepting negative numbers. Then again, I guess you can produce very strange bugs by passing in negative numbers and all that good stuff, so breaking that pattern intentionally may actually be a good idea.
@davr1
@davr1 Күн бұрын
I can think of two reasons One is that indexOf returns -1 if no result is found, which would produce strange bugs like you mentioned Another is that range syntax like ^10..^5 would become too ambiguous with negative numbers: -10..-5 might as well be - (10..-5) with an unary operator
@dmstrat
@dmstrat Күн бұрын
Resharper used to use terms like EOL and BOL style and now apparently they are using 'K&R" and "BSD" styles along with a few others that, frankly, are even worse. It seems easier to go with something that always works in the code instead of conditionally using the first 3 for many reasons including the ones you pointed out: lost scope being the big one. Codacy and SonarQube will also allow the restriction on formatting along with many other stylecop settings in your IDE making the conditional use of 3 of the 4 instead of "just do it this way across the board" makes it more maintainable to the next developer for this product. The EOL (or K&R now) style I use in Java while BOL (or BSD) style I used in C#. But if it is your personal project, you do you!
@jeroboam4486
@jeroboam4486 Күн бұрын
It makes the code less readable, soon it's gonna look like Brainfuck! Linq is fine.
@izzyblackout1090
@izzyblackout1090 Күн бұрын
How does it handles out of bound cases?
@mindstyler
@mindstyler 10 сағат бұрын
Indexoutofboundsexception like always if course
@Rick104547
@Rick104547 Күн бұрын
Quite a niche use case, would rather see something like discriminated unions.
@kejansenz
@kejansenz Күн бұрын
Maybe for the 2nd last item. But for the last item .LastOrDefault() should suffice. .Net Aspire for cloud ready apps is something I'm interested in. I would advice to Microsoft to invest more resources in fixing the many bugs in MAUI. Xamarin Forms is still way more stable.
@alexclark6777
@alexclark6777 Күн бұрын
Thank goodness they're working on these useful features instead of niche requests like discriminated unions. /s
@ralfwarnat9257
@ralfwarnat9257 21 сағат бұрын
is that related to criminal records?
@alexclark6777
@alexclark6777 2 сағат бұрын
@@ralfwarnat9257 No, those guys are in a protected class.
@triGataro
@triGataro Күн бұрын
so Python #?
@francajosejunior
@francajosejunior Күн бұрын
Realy cool! Awesome content!
@paulovictor9439
@paulovictor9439 Күн бұрын
Still no discriminated unions...
@JanMitkowski
@JanMitkowski Күн бұрын
I remember seeing this ^1 for C# 8.0. VS was changing .lenght-1 to this notation.
@onyxgc2568
@onyxgc2568 Күн бұрын
c# having an identity crisis
@fsharplove
@fsharplove Күн бұрын
A language with DU is really wanted by .NET developers and also a stable language. The result of adding too much features is that there is no idiomatic C# . General .NET developers are not aware that there are more than one language in .NET.
@justinth83
@justinth83 Күн бұрын
Exactly this. Maybe we should just be thankful there isn't a new way to check for null in the next release?
@Sqrlmasta
@Sqrlmasta 20 сағат бұрын
F# is a stable .NET language that supports discriminated unions... what's wrong with that?
@justinth83
@justinth83 46 минут бұрын
@@Sqrlmasta a good point and absolutely nothing wrong with F#, it's a great language. Curious though: assuming you use F# regularly, does it feel it gets the attention it deserves from MS or has it fallen by the wayside? I personally felt it never got the attention it deserved and has always been in C#'s shadow. I also seem to recall some recent features added to the .NET platform didn't play well with F# (sorry I forgot which exactly) which makes me wonder if MS do much testing or dog-fooding with F# these days (I would be surprised if they do).