Question

Create a new project in Visual Studio using C# Console Project. Declare an array of strings...

Create a new project in Visual Studio using C# Console Project. Declare an array of strings with the size of 12. Insert 12 different strings into the array. In a foreach loop display the contents of the array to the console.

Homework Answers

Answer #1

using System;

class Array
{
static void Main()
{
//string array declaration
string[] str = new string[12] {"hi", "hello", "how", "are", "you", "ok", "bye", "done", "yes", "no", "bye", "ok"};
  
//integer variable declaration and initialization
int k=0;
  
//display the array content on the computer screen
foreach (string i in str)
{
Console.WriteLine("str[{0}] = {1}", k, i);
k = k + 1;
}
}
}

OUTPUT:

str[0] = hi
str[1] = hello
str[2] = how
str[3] = are
str[4] = you
str[5] = ok
str[6] = bye
str[7] = done
str[8] = yes
str[9] = no
str[10] = bye
str[11] = ok


Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create a Visual Studio console project named exercise071 containing a main() program that in a single...
Create a Visual Studio console project named exercise071 containing a main() program that in a single statement declares an int array named primes and initializes the 5 entries to the first prime numbers. The primes start at 2 since 1 is not a prime number. Display the array on a single console line beginning with "Primes: " and a blank separating the numbers. A loop is not required.
Microsoft Visual Studio in C#: I have this code and need to loop through each element...
Microsoft Visual Studio in C#: I have this code and need to loop through each element of the patient's array and add to a listbox (lbAccountDisplay) each property of the patient's object. This is the 2nd time to ask this question; it should have all the detail you need to help me. It is a piece of a project and I am trying not to give you the whole project. How do I use a foreach loop to loop through...
VISUAL STUDIO (NO JAVA CODING) Create a C# Console Application project to compute the tuition fee...
VISUAL STUDIO (NO JAVA CODING) Create a C# Console Application project to compute the tuition fee a student should pay. In this part of the assignment, you are required to create a C# Console Application project. Project name should be A2<FirstName><LastName>P1. For example a student with first name John and Last name Smith would name the project A2JohnSmithP1. Step 1: Ask if a student is a Canadian Citizen or an International Student. Also ask for their age. You must use...
Questions: 1. (5 marks) Create a VB.NET Console Application that defines a function Smallest and calls...
Questions: 1. Create a VB.NET Console Application that defines a function Smallest and calls this function from the main program. The function Smallest takes three parameters, all of the Integer data type, and returns the value of the smallest among the three parameters. The main program should (1) Prompt a message (using Console.WriteLine) to ask the user to input three integers. (2) Call the built-in function Console.ReadLine() three times to get the user’s input. (3) Convert the user’s input from...
Create a class called BirthYear. It should only have two member, both of them arrays. One...
Create a class called BirthYear. It should only have two member, both of them arrays. One of type string called Names. The second of type int called BirthYears. in your main class create a StudentBirthYear object. Make sure both arrays are of the size 10. Add ten different names and ten different birth years. Then display each name with its birth year using only 1 for loop. (You can display in a for loop as well as a foreach loop,...
--USING C# ONLY-- You will create your own on-line shopping store in the console application. You...
--USING C# ONLY-- You will create your own on-line shopping store in the console application. You can choose different products to sell in your store (at least 8 products). You will create an product inventory text file. The program will display two options at the beginning of the program, Customer and Manager. Customer: If this is a new customer, the program will allow the customer to register with their information and assign a unique ID number to the new customer....
Subject- ( App Development for Web) ( language C#, software -visual studio) Exact question is-Firstly the...
Subject- ( App Development for Web) ( language C#, software -visual studio) Exact question is-Firstly the console calculator is created which perform multiply,divide,sub and add, operation and it accept all type of data (divide by 0 case as well ).Now the main motive is to create the library project from the console calculator project .Than we have to create a unit test project which test the functionality of added library.Make test like Test 1. multiply two positive number,Test 2. Add...
This problem is from Microsoft Visual C#: An Introduction to Object Oriented Programming (7th Edition) by...
This problem is from Microsoft Visual C#: An Introduction to Object Oriented Programming (7th Edition) by Joyce Farrell. This problem relies on the generation of a random number. You can create a random number that is at least min but less than max using the following statements: Random ranNumberGenerator = new Random(); int randomNumber; randomNumber = ranNumberGenerator.Next(min, max); Create a game similar to Hangman named GuessAWord in which a player guesses letters to try to replicate a hidden word. Store...
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns...
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns the index of the first occurance of the smallest value in the array. Your function must be able to process all the elements in the array. Create a function prototype and function definition (after the main function). Your main function should declare a 100 element integer array. Prompt the user for the number of integers to enter and then prompt the user for each...
C++ If necessary, create a new project named Introductory20 Project and save it in the Cpp8\Chap13...
C++ If necessary, create a new project named Introductory20 Project and save it in the Cpp8\Chap13 folder. Also create a new source file named Introductory20.cpp. Write a program that displays the appropriate shipping charge based on the region code entered by the user. To be valid, the region code must contain exactly three characters: a letter (either A or B) followed by two numbers. The shipping charge for region A is $25. The shipping charge for region B is $30....