Visual Studio 2015 C#6 replace INotifyPropertyChanged with nameof()

In Visual Studio 2015 with C#6.0 you can write your OnPropertyChange using the new nameof().

NotifyOfPropertyChange(() => Prop);

with

NotifyOfPropertyChange(nameof(Prop));

Regex for Visual Studio 2015 to find and replace:

Text to search:

(?:\()[()][)][ ][=][>] (.*)(?:\);)

Replace with:

(nameof($1));

Make sure the option “Use Regular Expressions” is enabled in the find and replace window.

Quick and dirty, comment your regex below🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s