【发布时间】:2012-02-21 01:27:30
【问题描述】:
我在模型中有一个List<string>。
当我写一个html helper时,我可以从metadata.Model获取数据,这是一个对象
// this is from MVC3 (namespace System.Web.Mvc -> ModelMetadata), I did not write this
// Summary:
// Gets the value of the model.
//
// Returns:
// The value of the model. For more information about System.Web.Mvc.ModelMetadata,
// see the entry ASP.NET MVC 2 Templates, Part 2: ModelMetadata on Brad Wilson's
// blog
public object Model { get; set; }
我的问题是:如何从Object 获取List<string>?
【问题讨论】:
-
对象的实际类型是什么?将 any 对象“转换”为某个字符串列表是没有意义的。
-
你是说类型转换? obj as List
?