Results 1 to 8 of 8
  1. #1
    iAmRishi's Avatar
    Join Date
    Aug 2014
    Gender
    male
    Posts
    17
    Reputation
    10
    Thanks
    2

    C# Multidimensional Array (Im completely lost)

    I am having a hard time doing this task. I have never really working with multidimensional arrays so any information on how to go about this or some code, anything would be appreciated.

    Task:
    for(int i -0, i<x; i++
    step 1: inout 1 name 1 object 1 action word
    step 2: store in 3darray [i,i,i]array
    Note: Must be stored in the same position in the array [anme,object,actionword]
    }

    any help would be appreciated

  2. #2
    NPDevTeam's Avatar
    Join Date
    Aug 2017
    Gender
    male
    Posts
    8
    Reputation
    10
    Thanks
    1
    Code:
    var myDictionary = new Dictionary<string, Dictionary<object, string>>();
                for (int i = 0; i < myDictionary.Count; i++)
                {
                    var element = myDictionary.ElementAt(i);
                    var name = element.Key;
                    var valueOfElement = element.Value;
                    for (int e = 0; e < valueOfElemen*****unt; e++)
                    {
                        var obj = valueOfElement.ElementAt(e).Key;
                        var actionWord = valueOfElement.ElementAt(e).Value;
                    }
                }
    to get actionword, for example -var actionword = myDictionary[name][object];
    Last edited by NPDevTeam; 09-19-2017 at 03:16 AM.

  3. #3
    iAmRishi's Avatar
    Join Date
    Aug 2014
    Gender
    male
    Posts
    17
    Reputation
    10
    Thanks
    2
    Quote Originally Posted by NPDevTeam View Post
    to get actionword, for example -var actionword = myDictionary[name][object];
    I needed to store all 3 in this Multidimensional array[name,object,acitonW] heres the concept in my mind, Let me know if thats what you did.

    Code:
                    for(int i=0; i<=totalWords; i++)
                    {
                        Console.WriteLine("Please enter name#" + i + ":");
                        Console.WriteLine("Please enter verb#" + i + ":");
                        Console.WriteLine("Please enter action#" + i + ":");
                        //This is the hard part tho... I need to store those 3 different string inputs into an multidimensional array 
                        array[weord,verb.action] //Has to be stored in the same index                }

  4. #4
    Zaczero's Avatar
    Join Date
    Oct 2013
    Gender
    male
    Location
    localhost
    Posts
    3,288
    Reputation
    1517
    Thanks
    14,262
    My Mood
    Angelic
    Quote Originally Posted by iAmRishi View Post
    I needed to store all 3 in this Multidimensional array[name,object,acitonW] heres the concept in my mind, Let me know if thats what you did.

    Code:
                    for(int i=0; i<=totalWords; i++)
                    {
                        Console.WriteLine("Please enter name#" + i + ":");
                        Console.WriteLine("Please enter verb#" + i + ":");
                        Console.WriteLine("Please enter action#" + i + ":");
                        //This is the hard part tho... I need to store those 3 different string inputs into an multidimensional array 
                        array[weord,verb.action] //Has to be stored in the same index                }
    You don't need multi-dim array.
    You can use new Tuple array for this.

    Code:
    (string name, string verb, object action)[] myTupleArray = new (string, string, object)[totalWords];
    
    ... for ...
    myTupleArray[i] = (userInput.Name, userInput.Verb, userInput.Action);
    ... /for ...
    TIP: Don't forget to download System.ValueTuple from nuget
    Last edited by Zaczero; 09-19-2017 at 02:48 PM.
    . . . malsignature.com . . .



    [ global rules ] [ scam report ] [ image title ] [ name change ] [ anime force ]
    [ league of legends marketplace rules ] [ battlefield marketplace rules ]

    "because everytime you post a picture of anime in here
    your virginity's time increases by 1 month"
    ~Smoke 2/18/2018


    Former Staff 09-29-2018
    Battlefield Minion 07-21-2018
    Premium Seller 03-04-2018
    Publicist 12-10-2017
    League of Legends Minion 05-31-2017
    Premium 02-05-2017
    Member 10-13-2013

  5. The Following User Says Thank You to Zaczero For This Useful Post:

    Colassall (10-15-2017)

  6. #5
    iAmRishi's Avatar
    Join Date
    Aug 2014
    Gender
    male
    Posts
    17
    Reputation
    10
    Thanks
    2
    Thank you all for coming to my support. THis is now solved and here is what I did.

    Code:
    string[,] Arra = new string[3, 9];
    for (int a = 0; a <= (totalWords - 1); a++)
    {
    Console.WriteLine("Please enter name#" + (a + 1) + ":");
    Arra[0, a] = Console.ReadLine();
    }

  7. #6
    Colassall's Avatar
    Join Date
    Oct 2016
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    1
    My Mood
    Bored
    Quote Originally Posted by Zaczero View Post


    You don't need multi-dim array.
    You can use new Tuple array for this.

    Code:
    (string name, string verb, object action)[] myTupleArray = new (string, string, object)[totalWords];
    
    ... for ...
    myTupleArray[i] = (userInput.Name, userInput.Verb, userInput.Action);
    ... /for ...
    TIP: Don't forget to download System.ValueTuple from nuget
    Not to necro, but wanted to say thanks for this. I've been fiddling with swapping arrays, datasets, and sqlite connectors for a work project for about 2 weeks and I think this may have just solved my problem.

  8. The Following User Says Thank You to Colassall For This Useful Post:

    Zaczero (10-15-2017)

  9. #7
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Quote Originally Posted by Zaczero View Post


    You don't need multi-dim array.
    You can use new Tuple array for this.

    Code:
    (string name, string verb, object action)[] myTupleArray = new (string, string, object)[totalWords];
    
    ... for ...
    myTupleArray[i] = (userInput.Name, userInput.Verb, userInput.Action);
    ... /for ...
    TIP: Don't forget to download System.ValueTuple from nuget
    In before this gets marked as incorrect by incompetent teachers <:
    Ah we-a blaze the fyah, make it bun dem!

  10. The Following 3 Users Say Thank You to Hell_Demon For This Useful Post:

    iAmRishi (10-19-2017),Silent (10-18-2017),Zaczero (10-16-2017)

  11. #8
    Colassall's Avatar
    Join Date
    Oct 2016
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    1
    My Mood
    Bored
    Yeah a teacher might mark that off, but in a work place if it works and doesn't take ages it's a good solution (barring any security issues, but it's all offline). I'm self taught and my C# is terrible (it's not my job to code I do it to save time) so it works for me lol.

Similar Threads

  1. [Help] Noob completly lost.
    By BlaBulle in forum General Hacking
    Replies: 7
    Last Post: 10-19-2016, 03:37 AM
  2. Bleach vs Battlestar vs Lost
    By arunforce in forum General
    Replies: 23
    Last Post: 09-25-2009, 11:58 AM
  3. I eat trees (lost thread)
    By Chronologix in forum Help & Requests
    Replies: 14
    Last Post: 01-27-2006, 09:29 PM
  4. My First completed Siggy!
    By h0ang in forum Art & Graphic Design
    Replies: 1
    Last Post: 01-26-2006, 09:11 AM
  5. Lost
    By kvmn8 in forum Entertainment
    Replies: 6
    Last Post: 01-25-2006, 06:56 PM