'How to write a for loop in LINQ

one question bothers me. I'm reading a file that has coordinates(longitude and latitude).

The contents of the file: 50.29264389999999,18.91857099999993;50.0347499,21.967057000000068;54.4547473,17.042384500000026;

I made a class for the coordinates

internal class Coordinate
    {
        public double Longitude { get; set; }
        public double Latitude { get; set; }
        public Coordinate(double longitude,double latitude)
        {
            this.Longitude = longitude;
            this.Latitude = latitude;
        }
    }

And I use this code to read the file and list them.

List<Coordinate> cordinates = new List<Coordinate>();
var items = File.ReadAllText("../../../Files/input-01.txt").Split(new char[] { ',', ';' }).Select(double.Parse).ToList();
for(int i = 0; i < items.Count; i+=2)
{
    cordinates.Add(new Coordinate(items[i], items[i + 1]));
}            

The program works, but is there a way to write this for loop in LINQ ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source