fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. //other streamreader code
  14. string strTemp = String.Empty;
  15. string[] splitsByLine = new string[] { "1, 2, 3, 4",
  16. ",,,",
  17. "x,y,z",
  18. "" };
  19.  
  20. if (splitsByLine != null && splitsByLine.Any())
  21. {
  22. foreach (string s in splitsByLine)
  23. {
  24. strTemp = s.Replace(",", "");
  25.  
  26. if (!String.IsNullOrEmpty(strTemp))
  27. {
  28. var nameAndSize = s.Split(',');
  29.  
  30. if (nameAndSize != null && nameAndSize.Any() && nameAndSize.Count() > 1)
  31. {
  32. Console.WriteLine(String.Concat(nameAndSize[0]));
  33. }
  34. }
  35. }
  36. }
  37. }
  38. }
  39. }
  40.  
Success #stdin #stdout 0.03s 24232KB
stdin
Standard input is empty
stdout
1
x