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 8920677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:20:12+00:00 2026-06-15T06:20:12+00:00

EDITED CODE the text file with the rows I am trying to reverse contains

  • 0

EDITED CODE

the text file with the rows I am trying to reverse contains these numbers:

1 2 3 4 5 6 7 8 9 10  
11 12 13 14 15 16 17 18 19 20  
21 22 23 24 25 26 27 28 29 30  
31 32 33 34 35 36 37 38 39 40  
41 42 43 44 45 46 47 48 49 50  
51 52 53 54 55 56 57 58 59 60  
61 62 63 64 65 66 67 68 69 70  
71 72 73 74 75 76 77 78 79 80  
81 82 83 84 85 86 87 88 89 90  
91 92 93 94 95 96 97 98 99 100  

so far my array looks like this:

 static void Main()
    {            
            int numbers;

            StreamReader fileReader = new StreamReader(fileDirectory);
            string line  = fileReader.ReadLine();
            fileReader.Close();
            string[] Split = line.Split();
            int.TryParse(line, out numbers);

            int[,] Table = new int [10,10];

                for (int row = 0; row < Table.GetUpperBound(0); row++)
                {
                    for (int column = 0; column < Table.GetUpperBound(0); column++)
                    {

                    }
                }


                for (int row = 0; row < Table.GetUpperBound(0); row++)
                {
                    for (int column = 0; column < Table.GetUpperBound(0); column++)
                    {
                        int tempHolder = Table[row, column];
                        Table[row, column] = Table.GetUpperBound(0);
                        Table[row, Table.GetUpperBound(0) - column] = tempHolder;
                        Console.WriteLine(Table[row, column]);
                        Console.Write(" ");
                    }
                    Console.WriteLine();
                }Console.Write(" ");
        }

can you help me with adding the int numbers variable to the array and then I will attempt the reversing. Right now if I run this I get about 24 lines of the number 9. Also can someone show me how to do a 2d array without having to specify the size of it? I have looked online but cant find out how. Thanks

  • 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-15T06:20:15+00:00Added an answer on June 15, 2026 at 6:20 am

    I assume this is homework, so I’ll give some advice but stop short of actually providing code.

    Firstly, you’ll have to Split each line to get a list of strings representing each number.
    After that you need to Convert the string representation of each number to an integer.
    Then it shouldn’t be too hard to loop through and add each int to the array.
    You will need to keep track of the current horizontal index while processing a line, and vertical index across all lines.

    After that you should be much closer. Have a go at doing the reversal and come back if you have problems again.

    Edit:

    For creating the array, you can specify the size from int variables. If you had String[] lines (one for each line) and String[] line (a line from lines split by the space character), you could declare the array like so:

    int[,] table = new int[line.Length, lines.Length];
    

    You’re getting pretty close with this code.
    For String.Split, you need to tell it which character separates the elements you want:

    String[] split = line.Split(' ');
    

    This needs to be done once for each line in the file, so it should be moved inside the outer loop. Similarly, int.TryParse needs to be done once for each number, so it should be inside the inner loop.

    int number;
    if (int.TryParse(split[column], out number))
    {
        table[column, row] = number;
    }
    

    You should also watch your GetUpperBound calls. GetUpperBound(d) returns GetLength(d) - 1 so you need to loop while the index is les than or equal to GetUpperBound. You could also replace the GetUpperBound calls with GetLength(0) (Columns) and GetLength(1) (rows).
    The number passed to GetUpperBound and GetLength is the direction you want to get the size in. You’re passing 0 to all of these, which won’t work unless the array is square.

    In the reversing loops, there’s an error on the second line of the inner loop. You’re setting Table[row, column] to the size of the array, instead of the element to be swapped. You also only need to loop in to the middle of each row, otherwise you’ll just swap the elements back to their original positions on the last half.

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

Sidebar

Related Questions

Let's say I have a text file. It contains harmfull code like: <?php phpinfo();
using Matt's util code (a bit edited for Unicode text) public class GridViewExportUtil {
I'm trying to reutilize code that generates FILE fields for use when something is
I've already got some code to read a text file using fscanf() , and
i want to write a code in a way,if there is a text file
I am trying to process a text file of more than 1GB and saving
I have the following jQuery code in my PHP file (edited Jan 19 2010
I am trying to create a text file of the path and file name
I'm trying to read in a text file in a c# application, but I
I have been trying to load a text file into a combobox, and then

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.