Skip to content

Instantly share code, notes, and snippets.

@Abiwax
Last active September 20, 2016 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Abiwax/a56d0d4221f5e347ce58b284780d1265 to your computer and use it in GitHub Desktop.
Save Abiwax/a56d0d4221f5e347ce58b284780d1265 to your computer and use it in GitHub Desktop.
Simple array example in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassTutorial1
{
class Program
{
public void FindName(string[] student, string name)
{
foreach (string s in student)
{
if (s == name)
{
Console.WriteLine("I found " + name);
}
}
Console.WriteLine("End");
}
/*public void FindFailed(string[] student, int[] java, int[] stats)
{
for (int i = 0; i < student.Length; i++)
{
if (java[i] < 50 || stats[i] < 50)
{
Console.WriteLine("List of students who failed include:" + student[i]);
}
}
Console.ReadLine();
}
public void findAgeAverage(int[] age)
{
int sum = age.Sum();
decimal average = (decimal)sum / age.Length;
Console.WriteLine("The average age: "+ average.ToString("#.##"));
Console.WriteLine("end");
Console.ReadLine();
}
*/
static void Main(string[] args)
{
Console.WriteLine("Nothing yet");
Console.ReadLine();
string[] name = new string[] { "Tom", "Sreejata", "Kashif" };
int[] java = new int[] { 70, 88, 30 };
int[] statistics = new int[] { 76, 40, 90 };
int[] age = new int[] { 20, 22, 25 };
/*string[] name = new string[] { "Tom", "Sreejata", "Kashif" };
int[] java = new int[] { 70, 88, 30 };
int[] statistics = new int[] { 76, 40, 90 };
int[] age = new int[] { 20, 22, 25 };
Program pr = new Program();
Console.WriteLine("Please input the name you want to search for:");
string namevalue = Console.ReadLine();
pr.FindName(name, namevalue);
pr.FindFailed(name, java, statistics);
pr.findAgeAverage(age);*/
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment