Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help regarding code c#

Tags:

c#

I have class in 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> 
{ 
}

I just need to add multiple resource like

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" });

but the last line giving me the error when I want add multiple resources and each resource instance has property like url. I think i am wrong but not being able to capture where is there problem.

like image 845
Keith Costa Avatar asked Jun 21 '26 18:06

Keith Costa


1 Answers

I think your code should look like this:

cr.Resources.Add(new Resource(){ Url= @"\style\p1.css" });
cr.Resources.Add(new Resource(){ Url= @"\style\p2.css" });

Your current code is no valid C# code.

like image 170
Daniel Hilgarth Avatar answered Jun 24 '26 08:06

Daniel Hilgarth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!