Shortcut to get all private field names combined with && operator as a generated line of code?

Posted by burak ozdogan on Stack Overflow See other posts from Stack Overflow or by burak ozdogan
Published on 2010-05-12T12:26:56Z Indexed on 2010/05/12 12:34 UTC
Read the original article Hit count: 171

Hi,

Is it possible to use reflection when we write a code-template?

I was just thinking if it is possible to write a piece of code-template that will return me a list of all private field in the class separated by && operator in Visual Stuudio?

Let's say, I will enter "getAllPrivates&&" (or press a shortcut key) in the VS editor and it will return me something like this:

private bool _privateFiel1 = false;
private bool _privateFiel2 = true;
private bool _privateFiel3 = false;
private bool _privateFiel4 = false;
private bool _privateFiel5 = true;

// Here I press the shortcut or call the code-template and get his:

_privateFiel1 && _privateFiel2  && _privateFiel3 && _privateFiel4 && _privateFiel5

© Stack Overflow or respective owner

Related posts about visual-studio

Related posts about code-templates