本文整理汇总了C#中Location.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Location.Select方法的具体用法?C# Location.Select怎么用?C# Location.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Location
的用法示例。
在下文中一共展示了Location.Select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(String[] args)
{
var n = Convert.ToInt32(Console.ReadLine());
var a = new Location[n];
for (var i = 0; i < n; ++i) {
var line = Console.ReadLine().Split(new[] {' '});
a[i] = new Location {
Id = Convert.ToInt32(line[0]),
X = Convert.ToDouble(line[1]),
Y = Convert.ToDouble(line[2]),
};
}
var m = Convert.ToInt32(Console.ReadLine());
for (var i = 0; i < m; ++i) {
var line = Console.ReadLine().Split(new[] {' '});
var x = Convert.ToDouble(line[0]);
var y = Convert.ToDouble(line[1]);
double speed;
switch (line[2]) {
case "foot": speed = 5.0; break;
case "bike": speed = 15.0; break;
case "metro": speed = 20.0; break;
default: throw new Exception("unknown transport");
}
var minutes = Convert.ToDouble(line[3]);
var result = a
.Select(p => new { p.Id, Distance = GetDistance(x, y, p.X, p.Y) })
.Where(p => (p.Distance / speed) * 60.0 <= minutes)
.OrderBy(p => p.Distance)
.ThenBy(p => p.Id);
Console.WriteLine(string.Join(" ", result.Select(p => p.Id.ToString())));
}
}
示例2: GetScores
private Dictionary<Location, int> GetScores(Location[] canPutLocations, Dictionary<Location, int> cubeLengths, Dictionary<Location, int> heightMap)
{
return canPutLocations
.Select(location => new { location, score = GetScore(location, cubeLengths, heightMap) })
.ToDictionary(x => x.location, x => x.score);
}
示例3: Convert_Locations_To_Building
public static Building[] Convert_Locations_To_Building(Location[] its_locations)
{
return its_locations.Select(repLocation => repLocation.TheSelf).ToArray();
}