0% found this document useful (0 votes)
83 views3 pages

VALMONTE

The document contains code for 3 programs: 1) A one-dimensional array that stores the names of 6 classmates and prints them using a foreach loop. 2) A two-dimensional array initialized with the first 6 letters of the alphabet. 3) An ArrayList that contains strings, including "hello", and checks if a user-input string exists in the ArrayList.

Uploaded by

Xijhyve Mangana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views3 pages

VALMONTE

The document contains code for 3 programs: 1) A one-dimensional array that stores the names of 6 classmates and prints them using a foreach loop. 2) A two-dimensional array initialized with the first 6 letters of the alphabet. 3) An ArrayList that contains strings, including "hello", and checks if a user-input string exists in the ArrayList.

Uploaded by

Xijhyve Mangana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

FERDZ VALMONTE BSIT3.

1A
A one-dimensional array that contains six (6) names of your classmates. Then, print the
names using a foreach loop.

using System;
using System.Collections.Generic;
namespace ConsoleApp7
{

class Program
{
static void Main(string[] args)
{

String[] classmates = { "Kurt", "Piolo", "Wes", "Marvin", "William", "Johnrey" };

foreach (String classmate in classmates)


{
Console.WriteLine(classmate);
}
}
}

A two-dimensional array with two (2) rows and three (3) columns. Then, initialize the array
with the first six (6) letters of the alphabet as its elements.

using System;
using System.Collections.Generic;
namespace ConsoleApp7
{

class Program
{
static void Main(string[] args)
{

string[,] alphabets = new string[3, 2];

alphabets[0, 0] = "A";

This study source was downloaded by 100000862856773 from CourseHero.com on 04-14-2023 08:33:16 GMT -05:00

https://www.coursehero.com/file/116955345/VALMONTEdocx/
alphabets[0, 1] = "B";
alphabets[1, 0] = "C";
alphabets[1, 1] = "D";
alphabets[2, 0] = "E";
alphabets[2, 1] = "F";

foreach (string alpha in alphabets)


{
Console.WriteLine("letters: " + alpha);
}
}
}
}

A string with any message. Then, determine if the message contains the string, "hello".

using System;
using System.Collections;
namespace ConsoleApp7
{

class Program
{

public static void Main()


{

ArrayList Crossfire = new ArrayList();

This study source was downloaded by 100000862856773 from CourseHero.com on 04-14-2023 08:33:16 GMT -05:00

https://www.coursehero.com/file/116955345/VALMONTEdocx/
Crossfire.Add("hello");
Crossfire.Add("spop");
Crossfire.Add("sas");
Crossfire.Add("swat");
Crossfire.Add("omoh");
Crossfire.Add("sov");
Crossfire.Add("opes");
Console.WriteLine("Enter character name that exist inside of the array");
String characters = Console.ReadLine();
if (Crossfire.Contains(characters))
Console.WriteLine("The word is existed inside the array");
else
Console.WriteLine("The word does not exist inside the array");
}
}

This study source was downloaded by 100000862856773 from CourseHero.com on 04-14-2023 08:33:16 GMT -05:00

https://www.coursehero.com/file/116955345/VALMONTEdocx/
Powered by TCPDF (www.tcpdf.org)

You might also like