Navigation

    ask avan logo
    • Register
    • Login
    • Search
    • Categories
    • Unsolved
    • Solved

    Create a console application in C# that accepts three (3) programmer-defined values and save them to an array.

    C#
    2
    2
    134
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Charles Craft50
      Charles Craft50 last edited by

      I don't get the question, what I'm supposed to create? We are currently in the OOP topic in C#;

      At the end of the exercise, the students should be able to:
      Create a C# program with classes to incorporate OOP concepts.

      Procedure:
      Create a console application in C# that accepts three (3) programmer-defined values and save them to an array.

      Reply Quote 1
        1 Reply Last reply

      • avan
        avan last edited by

        I think they just want you to initialize an array add three values to it. Here is how you can initialize an array and add values to it.

        Method 1:

        int[] arr = new int[5]
           arr[0] = 1;
           arr[1] = 2;
           arr[2] = 3;
        

        Method 2:

        int[] arr =new int[5] { 1, 2, 3 };
        

        https://www.completecsharptutorial.com/basic/storing-values.php

        Here 1,2,3 are programmer-defined the values

        I am not a C# sharp developer so I don't know how to create a console application. I found the following article that might need help get started in case you are confused about that part:

        https://docs.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio-code

        The only part I can't figure out if the one-line instructions above is asking for the values to be inputted through the command prompt. In that case you can use args in the main method to retrieve the command line arguments. The following article should have more info and even some examples.

        https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/main-and-command-args/command-line-arguments

        I hope this helps in some way.

        Reply Quote 0
          1 Reply Last reply

        • avan
          avan last edited by

          I think they just want you to initialize an array add three values to it. Here is how you can initialize an array and add values to it.

          Method 1:

          int[] arr = new int[5]
             arr[0] = 1;
             arr[1] = 2;
             arr[2] = 3;
          

          Method 2:

          int[] arr =new int[5] { 1, 2, 3 };
          

          https://www.completecsharptutorial.com/basic/storing-values.php

          Here 1,2,3 are programmer-defined the values

          I am not a C# sharp developer so I don't know how to create a console application. I found the following article that might need help get started in case you are confused about that part:

          https://docs.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio-code

          The only part I can't figure out if the one-line instructions above is asking for the values to be inputted through the command prompt. In that case you can use args in the main method to retrieve the command line arguments. The following article should have more info and even some examples.

          https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/main-and-command-args/command-line-arguments

          I hope this helps in some way.

          Reply Quote 0
            1 Reply Last reply

          • First post
            Last post