static void Main() { Path pointsPath = new Path(); pointsPath.AddPoint(new Point3D(10, 10, 10)); pointsPath.AddPoint(new Point3D(0.5, 0.3, 0.4)); pointsPath.AddPoint(new Point3D(0.7, 0.24, 5.73)); Console.WriteLine("Current points: "); Console.WriteLine(pointsPath.ToString()); // Save the points to the file PathStorage.Save(pointsPath, "Test.txt"); // Read the new points Path newPointsPath = PathStorage.Load("Test.txt"); Console.WriteLine("Points read from the file: "); Console.WriteLine(newPointsPath.ToString()); }
public static Path LoadPath() { Path loadPath = new Path(); using (StreamReader reader = new StreamReader("../../Saves.txt")) { while (reader.Peek() >= 0) { string line = reader.ReadLine(); string[] splittedLine = line.Split(new char[] {' ', '(', ',', ')' }, StringSplitOptions.RemoveEmptyEntries); loadPath.AddPoint(new Point3D(double.Parse(splittedLine[0]), double.Parse(splittedLine[1]), double.Parse(splittedLine[2]))); } return loadPath; } }
public static Path LoadPath(string filePath) { Path path = new Path(); using (StreamReader sr = new StreamReader(filePath)) { while (sr.EndOfStream == false) { string nextPointTxt = sr.ReadLine(); Point3D nextPoint = Point3D.Parse(nextPointTxt); path.AddPoint(nextPoint); } } return(path); }
public static Path LoadPath() { Path loadPath = new Path(); using (StreamReader reader = new StreamReader("../../Saves.txt")) { while (reader.Peek() >= 0) { string line = reader.ReadLine(); string[] splittedLine = line.Split(new char[] { ' ', '(', ',', ')' }, StringSplitOptions.RemoveEmptyEntries); loadPath.AddPoint(new Point3D(double.Parse(splittedLine[0]), double.Parse(splittedLine[1]), double.Parse(splittedLine[2]))); } return(loadPath); } }
static void Main(string[] args) { Point3D myPoint = new Point3D(1, 2, 3); Path.AddPoint(myPoint); Path.AddPoint(new Point3D(2, 3, 7)); Path.AddPoint(new Point3D(9, 2, 2)); Path.AddPoint(new Point3D(2, 7, 1)); PathStorage.SavePaths("../../text.txt"); Console.WriteLine(PathStorage.LoadPaths("../../text.txt")); GenericList <int> array = new GenericList <int>(10); array.Add(4); array.Add(6); array.Add(8); array.Add(3); array.Add(7); array.Add(1); for (int i = 0; i < array.Length; i++) { Console.WriteLine(array[i]); } Console.WriteLine(); array.Remove(2); for (int i = 0; i < array.Length; i++) { Console.WriteLine(array[i]); } Console.WriteLine(new string('-', 20)); Console.WriteLine("Max element is: " + array.Max()); Console.WriteLine(new string('-', 20)); Type type = typeof(Program); object[] allAttibutes = type.GetCustomAttributes(false); foreach (VersionAttribute attribute in allAttibutes) { Console.WriteLine("Version is: " + attribute.Value); } }
public static Path LoadPath() { Path result = new Path(); using (StreamReader reader = new StreamReader("..//..//LoadPaths.txt")) { char[] separators = { ',', '(', ')', ' ' }; string line = reader.ReadLine(); while (line != null) { Point3D point = new Point3D(); string[] points = line.Split(separators, StringSplitOptions.RemoveEmptyEntries); point.XCoord = int.Parse(points[0]); point.YCoord = int.Parse(points[1]); point.ZCoord = int.Parse(points[2]); result.AddPoint(point); line = reader.ReadLine(); } } return result; }
public static Path Load(string fileName) { if (string.IsNullOrEmpty(fileName)) { throw new ArgumentException("The name of the file cannot be empty."); } string line = string.Empty; Path pointsPath = new Path(); using (var file = new StreamReader(fileName)) { while ((line = file.ReadLine()) != null) { double[] coords = line.Split(new char[] { '{', ',', ' ', '}' }, StringSplitOptions.RemoveEmptyEntries) .Select(x => double.Parse(x)) .ToArray(); pointsPath.AddPoint(new Point3D(coords[0], coords[1], coords[2])); } } return pointsPath; }
public static Path Load(string fileName) { if (string.IsNullOrEmpty(fileName)) { throw new ArgumentException("The name of the file cannot be empty."); } string line = string.Empty; Path pointsPath = new Path(); using (var file = new StreamReader(fileName)) { while ((line = file.ReadLine()) != null) { double[] coords = line.Split(new char[] { '{', ',', ' ', '}' }, StringSplitOptions.RemoveEmptyEntries) .Select(x => double.Parse(x)) .ToArray(); pointsPath.AddPoint(new Point3D(coords[0], coords[1], coords[2])); } } return(pointsPath); }