Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string getString()
- {
- //<<<<<==============Country Search===================>>>>>
- Console.WriteLine("Enter the first letter of the countries you wish to search: "); //prompts user to enter the country
- char upperCaseInput = Console.ReadKey().KeyChar; //gets input as char
- string line = ""; //creates a empty string
- char[] charArr;
- //start reading lines
- while ((line = filePath.ReadLine()) != null)
- {
- if (line.Length > 0)
- {
- //split line into char array and then assign string array = Afghanistan,Kabul,30419928 intended result
- string[] lineArray = line.Split(new char[] { ',' });
- charArr = lineArray[0].ToCharArray(); //change to A,f,g,h,a,n,i,s,t,a,n char array
- if ((charArr[0].ToString()).Contains(upperCaseInput))
- {
- memberName.startsWith = true;
- if(memberName.startsWith)
- {
- countryItems.Add(" ");
- countryItems.Add(lineArray[0]);
- countryItems.Add(",");
- }
- }
- }
- }
- //transforms list into string for return output
- string newArray = string.Join("", countryItems );
- //<<<<<==============Capital Search to add later===================>>>>>//
- return newArray;
- }
- //executing write to control panel depending on userinput
- public void findAll()
- {
- List<string> newLines = new List<string>();
- newLines.Add(getString());
- foreach (string newline in newLines)
- {
- Console.WriteLine(newline);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement