Wassim AZIRAR Wassim AZIRAR - 1 year ago 96
C# Question

using a Code Snippet for INotifyPropertyChanged

I found this code snippet for INotifyPropertyChanged

But it shows the code like this :


I would have this :

  1. for public : capital letter for the first letter + ...

  2. for private : underscore + small letter for the first letter + ...

How can I achieve this ?

Edit : Without having to type the public and the private fields

<ToolTip>Property type</ToolTip>
<ToolTip>Property name</ToolTip>
<ToolTip>name of method to raise PropertyChanged event</ToolTip>
<Code Language="csharp">
<![CDATA[private $type$ _$property$;
public $type$ $property$
get { return _$property$;}
if (value != _$property$)
_$property$ = value;

Answer Source

I don't think this can be done with native code snippets feature provided by Visual Studio.

Personally I use Resharper which makes it possible. It can turn code I write like

public string Name { get; set; }


private string _name;
public string Name
    get { return _name; }
        if(value == _name)
        _name = value;

It even generates the OnPropertyChanged() method for you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download