none
does not contain a constructor that takes '0' arguments

    Question

  • /// Generic item data model.
        /// </summary>
        public class SampleDataItem : SampleDataCommon
        {
            publicSampleDataItem(String uniqueId, String title, String imagePath, String description, String content, SampleDataGroup group)
                : base(uniqueId, title, imagePath, description)
            {
                this._content = content;
                this._group = group;
            }


            public SampleDataItem(string p1, string p2, string p3, string p4, string p5, string ITEM_CONTENT, SampleDataGroup group1)
            {
                // TODO: Complete member initialization
                this.p1 = p1;
                this.p2 = p2;
                this.p3 = p3;
                this.p4 = p4;
                this.p5 = p5;
                this.ITEM_CONTENT = ITEM_CONTENT;
                this.group1 = group1;
            }


            private string _content = string.Empty;
            public string Content
            {
    Saturday, March 17, 2012 1:56 AM

Answers

  • My best guess is to change to the following.  You really need to understand how constructors in inherited classes work before inheriting from these.  Also, meaningful names to parameters would be beneficial, as those are exposted to callers in intellisense.  No one (but you) will know what a p1,versus a p4 means.
     
      public SampleDataItem(String p1, String p2, String p3, string p4, string p5,
       string ITEM_CONTENT, SampleDataGroup group1)
       : base (p1, p2, p3, p4)
      {
       // TODO: Complete member initialization
       this.p1 = p1;
       this.p2 = p2;
       this.p3 = p3;
       this.p4 = p4;
       this.p5 = p5;
       this.ITEM_CONTENT = ITEM_CONTENT;
       this.group1 = group1;
      }

    --
    Mike
    • Marked as answer by alexispoo Saturday, March 17, 2012 3:26 AM
    Saturday, March 17, 2012 3:20 AM

All replies

  • It seems you are having trouble posting your entire code into your question.  Rather than doing that, why not show us only the constructors, and show us where you are getting the error that you refered to in the title, that there is no constructor taking zero parameters.  To ask this question you should not need the entire set of code.

    --
    Mike
    Saturday, March 17, 2012 2:01 AM
  • here you can see tha main  

    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/1e259c22-8a71-4667-9d1b-be81f6878f22

    help please bro i dont know what to do anymore ;(

    Saturday, March 17, 2012 2:18 AM
  • It is telling you that SampleDataCommon does not have a zero parameter constructor.
     
    You need to either call the base constructor with four parameters, or give SampleDataCommon a zero parameter constructor.

    --
    Mike
    Saturday, March 17, 2012 2:22 AM
  • YES, but how do i put the constructor parameter and where :P

    im kind of new to this stily of programing

    Saturday, March 17, 2012 2:32 AM
  • Your "other" constructor calls the four-parameter constructor in using the : base (uniqueId, title, imagePath, description) in the first constructor for your class SampleDataGroup.  Not knowing what p1, p2, p3 and p4 are in your second constructor, my guess is that you should change your second constructor to this:
     
      public SampleDataGroup(string p1, string p2, string p3, string p4)
       : base(p1, p2, p3, p4)
      {
       // anything else you would want to do...
      }
       
    That is only a guess though, as p1.. p4 are not as descriptive as uniqueID, title, subtitle, imagePath and description.

    --
    Mike
    • Marked as answer by alexispoo Saturday, March 17, 2012 2:52 AM
    • Unmarked as answer by alexispoo Saturday, March 17, 2012 3:27 AM
    Saturday, March 17, 2012 2:39 AM
  • you made it man :), but: i have the same in this one :(




            public SampleDataItem(String p1, String p2, String p3, string p4, string p5, string ITEM_CONTENT, SampleDataGroup group1)
            {
                // TODO: Complete member initialization
                this.p1 = p1;
                this.p2 = p2;
                this.p3 = p3;
                this.p4 = p4;
                this.p5 = p5;
                this.ITEM_CONTENT = ITEM_CONTENT;
                this.group1 = group1;
            }

    i hope you help me more haha :) thank you anyway :D

    Saturday, March 17, 2012 2:52 AM
  • Assuming you still get the zero-parameter error on this constructor, what class does SampleDataItem inherit?
     
    When you inherit a class you by default call a parameterless constructor in all constructors of your inherited class.  To override this, you use the construct ": base(a, b, c)", in the constructor.  This signifies call a particular constructor in the base class, rather than the zero-parameter constructor.

    --
    Mike
    Saturday, March 17, 2012 3:09 AM
  •  public class SampleDataItem : SampleDataCommon
        {
            public SampleDataItem(String uniqueId, String title, String imagePath, String description, String content, SampleDataGroup group)
                : base(uniqueId, title, imagePath, description)
            {
                this._content = content;
                this._group = group;
            }


            public SampleDataItem(string p1, string p2, string p3, string p4, string p5, string ITEM_CONTENT, SampleDataGroup group1)
            {
                // TODO: Complete member initialization
                this.p1 = p1;
                this.p2 = p2;
                this.p3 = p3;
                this.p4 = p4;
                this.p5 = p5;
                this.ITEM_CONTENT = ITEM_CONTENT;
                this.group1 = group1;
            }

    This shows

    Saturday, March 17, 2012 3:14 AM
  • My best guess is to change to the following.  You really need to understand how constructors in inherited classes work before inheriting from these.  Also, meaningful names to parameters would be beneficial, as those are exposted to callers in intellisense.  No one (but you) will know what a p1,versus a p4 means.
     
      public SampleDataItem(String p1, String p2, String p3, string p4, string p5,
       string ITEM_CONTENT, SampleDataGroup group1)
       : base (p1, p2, p3, p4)
      {
       // TODO: Complete member initialization
       this.p1 = p1;
       this.p2 = p2;
       this.p3 = p3;
       this.p4 = p4;
       this.p5 = p5;
       this.ITEM_CONTENT = ITEM_CONTENT;
       this.group1 = group1;
      }

    --
    Mike
    • Marked as answer by alexispoo Saturday, March 17, 2012 3:26 AM
    Saturday, March 17, 2012 3:20 AM
  • OMG man you are a GOD!!! in this :D thanks so much you help me a lot i had those problems and i couldnt run my app thanks for your time and pacience :) 

    Alexis :)

    Saturday, March 17, 2012 3:26 AM