本文整理汇总了C#中Path.AddInPath方法的典型用法代码示例。如果您正苦于以下问题:C# Path.AddInPath方法的具体用法?C# Path.AddInPath怎么用?C# Path.AddInPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path.AddInPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
Console.WriteLine("------------------------------Ex.1------------------------------");
Point3D point = new Point3D(10, 20, 30);
Console.Write("Override ToString(): ");
Console.WriteLine(point.ToString());
//ex2
Console.WriteLine("------------------------------Ex.2------------------------------");
Console.WriteLine(Point3D.PointO);
//ex3
Console.WriteLine("------------------------------Ex.3------------------------------");
Console.Write("Distance : ");
Point3D point1 = new Point3D(0,0,0);
Point3D point2 = new Point3D(0,3,4);
Console.WriteLine(CalculateDistance.Calc(point1,point2));
Console.WriteLine("------------------------------Ex.4------------------------------");
Path path = new Path();
path.AddInPath(point1);
path.AddInPath(point2);
Console.WriteLine(path.Points[0]);
PathStorage.SaveData(path);
Path loadedPath = new Path();
loadedPath = PathStorage.LoadData();
Console.WriteLine("The loaded path has points :");
foreach (var item in loadedPath.Points)
{
Console.WriteLine(item);
}
}
示例2: LoadData
public static Path LoadData()
{
StreamReader reader = new StreamReader(dataPath);
Path newPath = new Path();
using (reader)
{
//firsl line of the file
string line = reader.ReadLine();
while (line != null)
{
string[] clearFormat = line.Split(new char[] {'[',']',','});//removing formats
// list to hold point coordinats
List<short> pointCoord = new List<short>();
for (int i = 0; i < clearFormat.Length; i++)
{
if (clearFormat[i] != "")
{
pointCoord.Add(short.Parse(clearFormat[i]));
}
}
//creating the point
Point3D pointForAdd = new Point3D(pointCoord[0],pointCoord[1],pointCoord[2]);
//adding point in the path
newPath.AddInPath(pointForAdd);
//taking the next line in the file
line = reader.ReadLine();
}
return newPath;
}
}