You are on page 1of 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