C
C#10mo ago
jacks

need blazor formatting help

i want this to display everything in a line but it's adding a break after each item
No description
10 Replies
jacks
jacksOP10mo ago
No description
jacks
jacksOP10mo ago
i want it to display like Current members: 1, 2, 3
Angius
Angius10mo ago
If bandMembers is a collection of strings in the format of memberx, you'll have to remove the member part of those strings With .Replace() for example And, with .Select(), you can do that to all elements of the collection So that you can, then, string.Join() the numbers Instead of inserting commas with that if/else
jacks
jacksOP10mo ago
can i have an example of how all of this would work
MODiX
MODiX10mo ago
Angius
REPL Result: Success
new[]{"fooa", "foob", "fooc"}.Select(s => s.Replace("foo", "bar"))
new[]{"fooa", "foob", "fooc"}.Select(s => s.Replace("foo", "bar"))
Result: List<string>
[
"bara",
"barb",
"barc"
]
[
"bara",
"barb",
"barc"
]
Compile: 387.423ms | Execution: 55.147ms | React with ❌ to remove this embed.
MODiX
MODiX10mo ago
Angius
REPL Result: Success
string.Join(" - ", new[]{ 1, 2, 3, 4 })
string.Join(" - ", new[]{ 1, 2, 3, 4 })
Result: string
1 - 2 - 3 - 4
1 - 2 - 3 - 4
Compile: 281.281ms | Execution: 41.370ms | React with ❌ to remove this embed.
jacks
jacksOP10mo ago
okay
jacks
jacksOP10mo ago
i was able to just completely get rid of the foreach and just do this
No description
Angius
Angius10mo ago
Yep
jacks
jacksOP10mo ago
ty for your help
Want results from more Discord servers?
Add your server