C
C#11mo 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
jacksOP11mo ago
No description
jacks
jacksOP11mo ago
i want it to display like Current members: 1, 2, 3
Angius
Angius11mo 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
jacksOP11mo ago
can i have an example of how all of this would work
MODiX
MODiX11mo 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
MODiX11mo 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
jacksOP11mo ago
okay
jacks
jacksOP11mo ago
i was able to just completely get rid of the foreach and just do this
No description
Angius
Angius11mo ago
Yep
jacks
jacksOP11mo ago
ty for your help

Did you find this page helpful?