I have a class that contains a load of properties that contain results of some calculations e.g:
public class Results
{
public double Result1 { get; set; }
public double Result2 { get; set; }
}
In a different class I am doing calculations to populate the above properties, e.g:
public class Calc
{
private Results Calc()
{
Results res = new Results();
res.Result1 = ... some calculation
res.Result2 = ... some other calculation
res.Result3 = ... // not yet defined in 'Results' class
return res;
}
}
When I am writing the Calc
class, Result3
will be highlighted in red as it is not yet defined in the Results
class.
Currently I am using the Resharper ALT + Enter shortcut, selecting "Create Property 'Result3'" which will create the following code int the Results
class:
public double Result3
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
Which I need to manually change to:
public double Result3 { get; set; }
Then I use the CTRL + Shift + Backspace shortcut to take me back to the Calc
class.
How can I easily create automatic properties in the Results
class if they are not yet defined directly from the Calc
class?
Configure individual keyboard shortcutsChoose Tools | Options from the menu and then go to Environment | Keyboard page. Use the shortcut tables to find the alias of the command, to which you are going to assign a new shortcut.
Here I am Showing You That How You Can Get & Set Property Using Shortcut In Visual Studio. Then it will automatically display intelligence & from that select "prop" & then press TAB key from your keyboard then it will automatically add a code snippet of get & set property.
In the Press shortcut key(s) box, enter the shortcut that you want to use. You can create a shortcut that combines a letter with the Alt key, the Ctrl key, or both. You can also create a shortcut that combines the Shift key and a letter with the Alt key, the Ctrl key, or both.
For Resharper 4/5, type prop
then tab, then fill in the required parameters.
Sounds like you'd like to stay in the Calc
class and create your properties in Results
in one go.
Here's what you do.
Turn on Solution-wide error checking (Resharper 5 is considerably better/faster)
Edit Calc
referring to all Results
properties, leaving the errors reported.
Hit Alt + Shift + PageDown. That will cycle you through all your errors.
Press Alt + Enter and choose Create Property and use the Auto-Property choice in Results
, then hit Alt + Shift + PageDown to
get back to Calc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With