© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
4 replies
OlipollyZ

❔ Backpack Array / C#

'using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace vektorerochsökning
{
internal class Program
{
static void Main(string[] args)
{

//Keep program running as long as the user doesn't choose to quit the program.
bool continueLoop = true;
//Create string vector with 5 elements
string[] myObject = new string[5];
myObject[0] = "";
myObject[1] = "";
myObject[2] = "";
myObject[3] = "";
myObject[4] = "";


while (continueLoop)
{
Console.WriteLine("This is a backpack, and this is what you can do with it");
Console.WriteLine("[1] Add a object");
Console.WriteLine("[2] Skriv ut alla föremål");
Console.WriteLine("[3] Sök i ryggsäcken");
Console.WriteLine("[4] Avsluta ryggsäcken");

//The user makes a choice
Console.Write("Choose: ");
int menuAlt = Convert.ToInt32(Console.ReadLine());

{
switch (menuAlt)
{
case 1: // Add a object (eg. fruit or something) - FOR every element in my vector
// Add a string value to the element
Console.WriteLine("What do you want to add to the backpack? ");
myObject = Console.ReadLine();
Console.WriteLine();

break;
}'
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

C# array init
C#CC# / help
2y ago
✅ Array help C++
C#CC# / help
2y ago
C# Array and Bubble Sort
C#CC# / help
2y ago
✅ DllImport a C-Styled array
C#CC# / help
4y ago