using System; using System.Linq; using System.Collections.Generic; public class championship_team { private int position_; private String team_; private int played_; private int won_; private int drawn_; private int lost_; private int for_; private int against_; private int goal_difference_; private int points_; public championship_team(int position, String team, int played, int won, int drawn, int lost, int for__, int against, int goal_difference, int points) { position_ = position; team_ = team; played_ = played; won_ = won; drawn_ = drawn; lost_ = lost; for_ = for__; against_ = against; goal_difference_ = goal_difference; points_ = points; } public string teamname { get { return team_; } set { } } public int goal_difference { get { return goal_difference_; } set { } } public int number_of_points { get { return points_; } set { } } public override string ToString() { return string.Format( " {0,3} {1,15} {2,3} {3,3} {4,3} {5,3} {6,3} {7,3} {8,3} {9,3} ", position_, team_, played_, won_, drawn_, lost_, for_, against_, goal_difference_, points_); } } public class football { public static int Main() { championship_team[] teams = { new championship_team (1,"QPR",7,6,1,0,19,2,17,19), new championship_team (2,"Ipswich Town",7,4,2,1,10,6,4,14), new championship_team (3,"Cardiff City",7,4,1,2,12,6,6,13), new championship_team (4,"Norwich City",7,4,1,2,10,8,2,13), new championship_team (5,"Watford",7,3,3,1,15,8,7,12), new championship_team (6,"Swansea City",7,4,0,3,10,7,3,12), new championship_team (7,"Doncaster",7,3,3,1,11,9,2,12), new championship_team (8,"Burnley",7,3,2,2,10,7,3,11), new championship_team (9,"Millwall",7,3,2,2,13,11,2,11), new championship_team (10,"Barnsley",7,3,2,2,13,12,1,11), new championship_team (11,"Coventry City",7,3,2,2,11,10,1,11), new championship_team (12,"Leeds United",7,3,2,2,10,10,0,11), new championship_team (13,"Middlesbrough",7,3,1,3,7,10,-3,10), new championship_team (14,"Sheffield Utd",7,3,1,3,4,9,-5,10), new championship_team (15,"Reading",7,2,3,2,9,8,1,9), new championship_team (16,"Scunthorpe",7,3,0,4,9,8,1,9), new championship_team (17,"Nottm Forest", 7,1,5,1,6,6,0,8), new championship_team (18,"Hull City",7,2,2,3,5,9,-4,8), new championship_team (19,"Crystal Palace",7,2,1,4,8,12,-4,7), new championship_team (20,"Derby County",7,1,2,4,7,11,-4,5), new championship_team (21,"Bristol City",7,1,2,4,7,13,-6,5), new championship_team (22,"Leicester City",7,1,2,4,6,12,-6,5), new championship_team (23,"Preston",7,1,0,6,5,14,-9,3), new championship_team (24,"Portsmouth",7,0,2,5,2,11,-9,2) }; print(teams, "These are the teams"); var sorted_by_name = from t in teams orderby t.teamname select t; print(sorted_by_name, "These are the teams sorted by name"); var sorted_by_goal_difference = from t in teams orderby t.goal_difference select t; print(sorted_by_goal_difference, "These are the teams sorted by goal difference"); var sorted_by_number_of_points = from t in teams orderby t.number_of_points select t; print(sorted_by_number_of_points, "These are the teams sorted by number of points"); return (0); } public static void print(IEnumerable x, string heading) { Console.WriteLine(" {0} ", heading); foreach (T i in x) Console.WriteLine(i); } }//