C
C#

help

How do I use String.Format with a multidimensional array?

Mmeizuflux2/23/2023
char[,] state = new char[3, 3] {
{'A', ' ', ' '},
{' ', ' ', ' '},
{' ', ' ', ' '}
};
//
// used like v I want the first column of the first row here
Console.WriteLine(String.Format(" -> {} ", state))
char[,] state = new char[3, 3] {
{'A', ' ', ' '},
{' ', ' ', ' '},
{' ', ' ', ' '}
};
//
// used like v I want the first column of the first row here
Console.WriteLine(String.Format(" -> {} ", state))
output should be A
AAngius2/23/2023
Console.WriteLine($" -> {state[0, 0]}");
Console.WriteLine($" -> {state[0, 0]}");
Mmeizuflux2/23/2023
Probably should have clarified, I know I can do that but with 9 elements it gets tedious Just curious if there was a better way
AAngius2/23/2023
Use a loop then And don't use String.Format() for such simple things
Mmeizuflux2/23/2023
Already wrote it out
AAngius2/23/2023
Well, if you have a loop, what doesn't work about it?
Mmeizuflux2/23/2023
It's more complicated than that, this is just an example No, I mean I already wrote it out by hand
AAngius2/23/2023
There's very little a String.Format() can do that string interpolation cannot
Mmeizuflux2/23/2023
Good to know Thanks for answering

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
❔ How do I Open Source Software correctly?I'm worried that I don't know how to OSS correctly. How do I choose a library? I want to write C# c❔ StreamerBot x Discord``` using System; using System.Runtime; using Twitch.Common.Models.Api; public class CPHInline { ❔ my API doesn't have an Startup.cs file<:Naomi:838549922235285516>✅ When and how should I use the Windows EventLog?Hello, do I need to create proper source via `EventLog.CreateEventSource`? If I need to, what is thwhere to learn crypterwhere to learn crypter✅ Practicing delegatesI've asked chat GPT to give me some good pseudo applications I could create with .NET, C# to practicHow to read CData from the xml?Hello, I have this code to read a xml from the web, but I dont know how to get the cdata with it. Ca❔ Newbie Q: Preventing double jump in unityIm making a platformer game and I want to prevent my character from jumping more than once. So I cre❔ Quick Question for a quiz gameDoes anyone have a good tutorial for a multiple choice quiz game using windows forms and people can ❔ Need some help/advicce on how to construct a multistep registration form (web api + react)Not user registration, listing registration So, when you register a listing on booking.com, they ha❔ "Invalid object name '...' "I am trying to use a Database first(model) with Reverse engineering from EF Core Power tool) but I h❔ Help with StreamReader txt filehello everybody! I'm trying to do a reading inside a .txt file, at first I type a name in a textbox ✅ Set TimeZone for request duration in ASP.NET CoreHey, I am generating PDFs on the server with ``DateTime`` objects. The problem is that my clients c✅ Can no longer run console app after adding unit testsI made a little test project that I've slowly been building onto. It's gotten big enough now that I'✅ Where can I learn crypterWhere can I learn how to code a fud or ud crypter. I have looked about it and couldnt find it. If y❔ How to design that?I wanna make freelance telegram bot, when client make order, he need to provide order title, details❔ MAUI custom content view only loads content correctly onceHey I have created a MAUI custom control using handlers that uses MapContent to render content in a ❔ OpenGL FPS drop / glitchy / laggy stuffI will send code in a bitnamespace fking me upwhy does it want to too add the whole domain.entity namespace when i have already added it, i rememb❔ Loading static data without Visual StudioI've got a number of static files (json, csv etc) that I need to make visible to my solution. On Vis