So You Think You Know C#? For vs Foreach

preview_player
Показать описание
You've been using the for and foreach statements for years now. But do you know what's really going on under the hood? Do you know which is faster and why?
Well, in this video I take you under the hood and show you what's really going on.
Рекомендации по теме
Комментарии
Автор

Great video Shiv. It was a short video but with lot of nuggets of information :)

VinuP
Автор

Awesome Video, Shiv!! such videos are treat for performance enthusiasts. I was not aware of foreach loop getting transformed to iterator like pattern.👍(I am not sure bt feels like await foreach became handy now that we know foreach gets lowered to iterator like pattern). I feel we can do one micro optimization in for loop instead of movies.Count in for loop we can replace it with local variable ( eg: totalCount = movies.Count). By using totalCount in loop instead of movies.Count jit potentially can eliminate bound check since it will see during compile time, local variable is not changing instead movies.Count could change because it could be assigned to a different list in a different method of the class✌️

sumitmore
Автор

Another example of Duck Typing in .NET is async/ await where Awaitable and Awaiter types also use Duck Typing. An awaitable type must implement a GetAwaiter method and the GetAwaiter must return a type that has a property IsCompleted, a method called GetResult and implements INotifyCompletion.

anandgupta
Автор

Informative.. Wanted to know how we can efficiently cache tables holding more than 1000 rows in c#. Tried static collection way but leads to leak so any help on this much appreciated. Thanks 😊

techypd
Автор

thank you Shiv and you have to take care about global virus

ademsenel
visit shbcf.ru