Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. public string getString()
  2. {
  3. //<<<<<==============Country Search===================>>>>>
  4. Console.WriteLine("Enter the first letter of the countries you wish to search: "); //prompts user to enter the country
  5. char upperCaseInput = Console.ReadKey().KeyChar; //gets input as char
  6. string line = ""; //creates a empty string
  7. char[] charArr;
  8.  
  9. //start reading lines
  10. while ((line = filePath.ReadLine()) != null)
  11. {
  12. if (line.Length > 0)
  13. {
  14. //split line into char array and then assign string array = Afghanistan,Kabul,30419928 intended result
  15. string[] lineArray = line.Split(new char[] { ',' });
  16.  
  17. charArr = lineArray[0].ToCharArray(); //change to A,f,g,h,a,n,i,s,t,a,n char array
  18.  
  19. if ((charArr[0].ToString()).Contains(upperCaseInput))
  20. {
  21. memberName.startsWith = true;
  22. if(memberName.startsWith)
  23. {
  24. countryItems.Add(" ");
  25. countryItems.Add(lineArray[0]);
  26. countryItems.Add(",");
  27. }
  28. }
  29. }
  30. }
  31. //transforms list into string for return output
  32. string newArray = string.Join("", countryItems );
  33.  
  34. //<<<<<==============Capital Search to add later===================>>>>>//
  35. return newArray;
  36. }
  37.  
  38. //executing write to control panel depending on userinput
  39. public void findAll()
  40. {
  41. List<string> newLines = new List<string>();
  42.  
  43. newLines.Add(getString());
  44.  
  45. foreach (string newline in newLines)
  46. {
  47.  
  48. Console.WriteLine(newline);
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement