Refactor or code snipple to generate a constructor based on instances variables

  • Thread starter Thread starter Ignacio Machin \( .NET/ C# MVP \)
  • Start date Start date
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


I have seen myself defining a class with a number of instances variables
and then creating properties around these variables, this is very easy as VS
2005 provide a refactor for this (Ctrl+r , Ctrl+e). But I often want to
create a constructor that receive one parameter per variable and assign it
to the variable.
a la:

classA
{
int i;
string s;

public ClassA(int i, string s)
{
this.i = i; this.s=s;
}

Does anybody knows of a tool that generate a constructor like that?

Thank,
 
I have seen myself defining a class with a number of instances variables
and then creating properties around these variables, this is very easy as VS
2005 provide a refactor for this (Ctrl+r , Ctrl+e). But I often want to
create a constructor that receive one parameter per variable and assign it
to the variable.

Does anybody knows of a tool that generate a constructor like that?

ReSharper will do this, certainly. (Alt+Insert)

Jon
 
Ignacio said:
I have seen myself defining a class with a number of instances variables
and then creating properties around these variables, this is very easy as VS
2005 provide a refactor for this (Ctrl+r , Ctrl+e). But I often want to
create a constructor that receive one parameter per variable and assign it
to the variable.
a la:

classA
{
int i;
string s;

public ClassA(int i, string s)
{
this.i = i; this.s=s;
}

Does anybody knows of a tool that generate a constructor like that?

SharpDevelop can (at least in newest version).

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top