Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8059023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:32:11+00:00 2026-06-05T09:32:11+00:00

in C# console app, how do you put the first digit of split string

  • 0

in C# console app, how do you put the first digit of split string into two dimensional array?

string[,] table3x3 = new string[3, 3];  
string myString = "11A23A4A5A87A5"; 
string[] splitA = myString.Split(new char[] { 'A' });

Let’s say I have 2-dimensional array of 3×3 and a string with numbers and a vowel. I split them so that I can put them inside the 2Darray. What kind of loop should I include so that the output would be

Console.WriteLine(table3x3[0, 0]); //output: blank
Console.WriteLine(table3x3[0, 1]); //output: blank
Console.WriteLine(table3x3[0, 2]); //output: 2
Console.WriteLine(table3x3[1, 0]); //output: blank
Console.WriteLine(table3x3[1, 1]); //output: 4
Console.WriteLine(table3x3[1, 2]); //output: 5
Console.WriteLine(table3x3[2, 0]); //output: 8
Console.WriteLine(table3x3[2, 1]); //output: blank
Console.WriteLine(table3x3[2, 2]); //output: 5

Visually, the output would be like:

[ ][ ][2]
[ ][4][5]
[8][ ][5]

There are 9 numbers and 5 vowels inside the string. It returns the first digit of split string into specific 2Darray according to their sequences.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T09:32:14+00:00Added an answer on June 5, 2026 at 9:32 am

    This should do it:

    string[,] table3x3 = new string[3, 3];  
    string myString = "11A23A4A5A87A5";
    
    int stringIndex = -1;
    bool immediatelyFollowsA = false;
    for (int row = 0; row < 3; row++)
        for (int col = 0; col < 3; col++)
        {
            while (myString[++stringIndex] == 'A')
            {
                immediatelyFollowsA = true;
            }
    
            if (immediatelyFollowsA)
            {
                table3x3[row,col] = myString[stringIndex].ToString();
                immediatelyFollowsA = false;
            }
        }
    

    Demo: http://ideone.com/X0LdF


    Or alternatively, adding to your original starting point:

    string[,] table3x3 = new string[3, 3];  
    string myString = "11A23A4A5A87A5";
    string[] splitA = myString.Split(new char[] { 'A' });
    
    int index = 0;
    bool first = true;
    foreach (string part in splitA)
    {
        int row = index / 3;
        int col = index % 3;
    
        if (!first)
        {
            table3x3[row, col] = part[0].ToString();
        }
    
        index += part.Length;
        first = false;
    }
    

    Demo: http://ideone.com/7sKuR

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASCII string (A null terminated char array) in a console app.
When an app have been put into the background and later resumes to an
I am trying to put two different UIPopovers in one view. I'm fairly new
I am new to C#. I have a menu in a console app. Now
I've got a console app that loads up a datatable; I'd like to export
I have a console app that performs a lengthy process. I am printing out
For an C# console app like this is it better to use xcopy or
I have console app A that references another console app B. B app has
I need a console app which will calling webmethod. It must be asynchronous and
I have a console app that's geared to be automatically ran as a Scheduled

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.