✅ How to write this as a one liner?

No description
29 Replies
Lucid-Jarne
Lucid-Jarne4w ago
No description
Angius
Angius4w ago
uh, string.Join() and a .Select()? Generally speaking, .ForEach() method is kinda frowned upon
Lucid-Jarne
Lucid-Jarne4w ago
Why?
Angius
Angius4w 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-Jarne4w 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
Angius4w 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 User4w ago
Message Not Public
Sign In & Join Server To View
Lucid-Jarne
Lucid-Jarne4w ago
So pretty much avoid the .ForEach()
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Lucid-Jarne
Lucid-Jarne4w ago
Even a normal foreach loop?
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Angius
Angius4w ago
Normal loop is fine It's recommended, even IIRC under some circumstances it's even faster than for?
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Lucid-Jarne
Lucid-Jarne4w ago
?
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Lucid-Jarne
Lucid-Jarne4w 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 User4w ago
Message Not Public
Sign In & Join Server To View
Lucid-Jarne
Lucid-Jarne4w ago
No it's just something from school to get us used to Entity core and stuff
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Angius
Angius4w ago
A console app? A website? A window app?
Lucid-Jarne
Lucid-Jarne4w ago
Like starting lectures about it how it can be used to generate code for us
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Lucid-Jarne
Lucid-Jarne4w ago
Console app
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Lucid-Jarne
Lucid-Jarne4w ago
Is there a reason to use var? or is that just a personal preference?
Angius
Angius4w ago
why write many letter when few letter do trick Up to preference, though
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
TizzyT
TizzyT3w ago
I disagree but this isnt the place so meh
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server