S
shapper
Hello,
I have the following class:
public class BoxLeaf {
public Box Box { get; set; }
public Validator Validator { get; set; }
public bool Validate() {
this.Validator.Add(Rule.NonEmpty(this.Box.Name), "Fill the
name");
return this.Validator.Success;
}
}
If I have something like:
BoxLeaf leaf = new BoxLeaf();
leaf.Validate();
Validate is not recognized.
If I change my code to:
public static bool Validate() {
this.Validator.Add(Rule.NonEmpty(this.Box.Name), "Fill the
name");
return this.Validator.Success;
}
Then I get the following error:
Keyword 'this' is not valid in a static property, static method, or
static field initializer
How should I do this?
Thanks,
Miguel
I have the following class:
public class BoxLeaf {
public Box Box { get; set; }
public Validator Validator { get; set; }
public bool Validate() {
this.Validator.Add(Rule.NonEmpty(this.Box.Name), "Fill the
name");
return this.Validator.Success;
}
}
If I have something like:
BoxLeaf leaf = new BoxLeaf();
leaf.Validate();
Validate is not recognized.
If I change my code to:
public static bool Validate() {
this.Validator.Add(Rule.NonEmpty(this.Box.Name), "Fill the
name");
return this.Validator.Success;
}
Then I get the following error:
Keyword 'this' is not valid in a static property, static method, or
static field initializer
How should I do this?
Thanks,
Miguel