2
我試圖在屬性屬於基類的類中查找屬性的用法。這裏是一個令牌例如:查找基礎實體的使用情況
class Program
{
class Item
{
public DateTime DeletedStamp { get; set; }
public decimal Price { get; set; }
}
class Book : Item
{
public string Title { get; set; }
public string Author { get; set; }
}
class Bicycle : Item
{
public string Type { get; set; }
public string Producer { get; set; }
}
static void Main(string[] args)
{
var book = new Book()
{
Title = "Atlas Shrugged",
Author = "Ayn Rand",
Price = 2.99M
};
var bicycle = new Bicycle()
{
Type = "Mountain bike",
Price = 499.99M,
Producer = "Biker Ben",
DeletedStamp = DateTime.Now
};
Console.WriteLine(book.Title);
Console.WriteLine(book.Price);
Console.WriteLine(bicycle.Price);
Console.WriteLine(bicycle.DeletedStamp);
}
}
如果我想找到的價格僅自行車項目的使用,我覺得我是運氣不好。我在Visual Studio 2013中使用重新清晰,查找用法查找所有使用價格,包括書中的用法。 這是一個小例子,但在許多其他類中使用了基類,因此無法追蹤使用情況。
我正在尋找任何提示,技巧,延伸或魔法來解決這個困境。
這很棒!我一直在尋找一種方法來做這件事很長一段時間,我被告知這是不可能的。 SO不同意:) – Maffelu 2014-11-10 07:07:06