nlanka 0 Newbie Poster
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Cities
    class Hometown

        public string City { get; set; }
        public string State { get; set; }

         public Hometown(string City, string State )
            this.City = City;
            this.State = State;

         public Hometown()



    class Program

            static void Main(string[] args)
            int counter = 0;
            string line;
            string  cities = "";
            string  states = "";

            List<Hometown> hometown = new List<Hometown> { new Hometown { }};
            int numStates = 0; 

            System.IO.StreamReader file =
   new System.IO.StreamReader("cities.txt");
            while ((line = file.ReadLine()) != null)


                string[] towninfo = line.Split(',');

                    cities = towninfo[0];// String on the left of the comma
                    states = towninfo[1]; // String on the right of the comma
                    hometown.Add(new Hometown(cities, states));



            var orderedHometowns = from h in hometown
                                   orderby h.City ascending
                                   select h;
            foreach (Hometown hometowns in orderedHometowns)
                var  cityQuery =
                            from h in hometown
                            from s in h.State
                            from c in s.City
                           where s.Equals(Console.ReadLine())

                foreach (var cs in cityQuery)




Here is what I need to do

Execute a Linq query to count how many records are in the list and present the total to the end user.

Execute a Linq query to sort the entries in the list in ascending order and present the list of cities to the end user, in order.
Execute a Linq query to find all states starting with a specific letter. Prompt the user for the letter they want to look for, then present those that start with that letter to them. There is no need at this time to validate that they entered a letter.
Execute a Linq query to find all states that are from a given state. Prompt the user for the state they want to look for, then present those that are from that state to them. Again there is no need to validate that they entered a valid state.

here is what I have in the text file

NewYork City,NY

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.