我有類在C#中關於代碼C#
public class CompositeResource : Control
{
[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public ResourceCollection Resources { get { return _resources; } }
}
public class Resource
{
[Bindable(true), DefaultValue(""), Editor("System.Web.UI.Design.UrlEditor, System.Design, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor)), Description("Specifies the URL of a resource to reference in the CompositeControl. The URL may be relative, root relative or absolute."), UrlProperty]
public String Url { get; set; }
[Bindable(true), DefaultValue(""), Description("Specifies the name of a resource to be used as a reference in the CompositeControl. The ReferenceName is typically used in conjunction with the Sprite control.")]
public String ReferenceName { get; set; }
}
public class ResourceCollection : List<Resource>
{
}
我只需要添加多個資源像
CompositeResource cr = new CompositeResource();
cr.Type = Xpedite.Resources.ResourceType.Css;
cr.ReferenceName = "hello";
cr.Resources.Add({new Resource().Url="\style\p1.css",new Resource().Url="\style\p2.css" });
但最後一行給我的錯誤,當我想要添加多個資源和需要幫助每個資源實例都有像url這樣的屬性。 我想我是錯了,但不能夠捕捉到哪裏有問題。
添加錯誤消息。也許可以去掉你的示例代碼來清除。 –
你會得到什麼錯誤? –
如果您遇到錯誤,請始終粘貼詳細信息。如果它是一個運行時錯誤,這應包括被拋出什麼異常爲主,堆棧跟蹤,如果你認爲異常被拋出的地方將是有益的,當然。如果其編譯錯誤,那麼編譯器消息和與其關聯的行。人們也許可以從剛剛代碼告訴,但沒有必要使它更難比它需要的。 :) – Chris