Class library usage, coding and language questions.
- Posts: 1
- Joined: Thu Nov 12, 2015 1:31 pm
Why exactly do you need a parameterless constructor in code modules?
Code: Select all
// Do not delete - a parameterless constructor is required!
I've run some test and they're working just fine without one. In C#, if you don't have any other constructors, you shouldn't have to define a parameterless constructor - it is automatically provided.
So, is there another reason Ranorex requires an explicit default constructor?
- Site Admin
- Posts: 12016
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
You are right, there is always an implicit parameterless constructor if (and only if) no other constructor (with parameters) is defined.
dankod wrote:So, is there another reason Ranorex requires an explicit default constructor?
No, Ranorex just needs a parameterless constructor to create the module at runtime. So the code for the parameterless constructor is there in case you define a second constructor with parameters. You can safely delete the parameterless constructor if you make sure, you don't create a constructor with parameters.