---
agentTools:
  projectIndex: https://objectfillernet.readme.io/llms.txt
---

# Handle Constructor Arguments

[block:api-header]
{
  "type": "basic",
  "title": "Documentation",
  "sidebar": true
}
[/block]

[block:textarea]
{
  "text": "With ObjectFiller.NET it is possible to instantiate objects which have a constructor **WITH ** arguments. \n\nIn the example the property `Address` in the class person gets ignored because it gets filled by the constructor. \n\nIt is also possible to define a setup for the `Address` by calling `.SetupFor<Address>` in the fluent API. The `address`argument in the constructor of class `Person` gets than filled with an `Address`object which matches the configuration. ",
  "sidebar": true
}
[/block]

[block:code]
{
  "codes": [
    {
      "code": "public class Person\n{\n  public Person(Address address)\n  {\n    Address = address;\n  }\n\n  public string Name { get; set; }\n  public string LastName { get; set; }\n  public int Age { get; set; }\n  public DateTime Birthday { get; set; }\n  public Address Address { get; set; }\n\n}\n\npublic class Address\n{\n  public string Street { get; set; }\n  public string City { get; set; }\n}\n\npublic class HelloFiller\n{\n  public void FillPerson()\n  {\n    Filler<Person> pFiller = new Filler<Person>();\n    pFiller.Setup()\n      .OnProperty(x=>x.Address).IgnoreIt();\n\n    Person filledPerson = pFiller.Create();\n  }\n}",
      "language": "csharp",
      "name": "Constructor parameters gets handled by the ObjectFiller"
    }
  ]
}
[/block]