C
C#2mo ago
Lucid-Jarne

✅ How to write this as a one liner?

No description
29 Replies
Lucid-Jarne
Lucid-JarneOP2mo ago
No description
Angius
Angius2mo ago
uh, string.Join() and a .Select()? Generally speaking, .ForEach() method is kinda frowned upon
Lucid-Jarne
Lucid-JarneOP2mo ago
Why?
Angius
Angius2mo ago
You can't really do anything with it's output since it's a void method, a regular foreach loop works just fine, and I believe there are some performance concerns as well
Lucid-Jarne
Lucid-JarneOP2mo ago
Yea but is the performance not going to get improved in .net 9? My prof has been talking about the fact that some thing like a .first wil get 1000x improvement
Angius
Angius2mo ago
Every version of .NET does get performance improvements, true Never heard anything specific to .ForEach() though Never seen anybody use it in the wild either, tbh
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Lucid-Jarne
Lucid-JarneOP2mo ago
So pretty much avoid the .ForEach()
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Lucid-Jarne
Lucid-JarneOP2mo ago
Even a normal foreach loop?
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Angius
Angius2mo ago
Normal loop is fine It's recommended, even IIRC under some circumstances it's even faster than for?
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Lucid-Jarne
Lucid-JarneOP2mo ago
?
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Lucid-Jarne
Lucid-JarneOP2mo ago
static void OpvragenEvenementen()
{
using (SportContext db = new SportContext())
{
List<Evenement> evenementen = db.Evenementen.ToList();
evenementen.ForEach(x => x.);
}
}
static void OpvragenEvenementen()
{
using (SportContext db = new SportContext())
{
List<Evenement> evenementen = db.Evenementen.ToList();
evenementen.ForEach(x => x.);
}
}
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Lucid-Jarne
Lucid-JarneOP2mo ago
No it's just something from school to get us used to Entity core and stuff
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Angius
Angius2mo ago
A console app? A website? A window app?
Lucid-Jarne
Lucid-JarneOP2mo ago
Like starting lectures about it how it can be used to generate code for us
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Lucid-Jarne
Lucid-JarneOP2mo ago
Console app
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Lucid-Jarne
Lucid-JarneOP2mo ago
Is there a reason to use var? or is that just a personal preference?
Angius
Angius2mo ago
why write many letter when few letter do trick Up to preference, though
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
TizzyT
TizzyT2mo ago
I disagree but this isnt the place so meh
Unknown User
Unknown User2mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server