c# - How can I make implementation of an interface produce an auto property instead of NotImplementedException? -
consider have simple interface such icar
when move mouse on icar expression , click on implement interface
visual studio produce below implementation.
is there way of providing auto property seen on interface. cause re-factoring issues , make me crazy each time!
public interface icar { double power { get; set; } } public class car:icar { public double power { { throw new notimplementedexception(); } set { throw new notimplementedexception(); } } }
you need change template used visual studio when click on implement interface
. template stored in following location:
c:\program files (x86)\microsoft visual studio 10.0\vc#\snippets\1033\refactoring
the template need change called propertystub.snippet
note: existing snippet file before making changes can revert if things not go well.
the lines need update are:
$getteraccessibility$ { $end$throw new $exception$(); } $setteraccessibility$ set { throw new $exception$(); }
the lines should changed this:
$getteraccessibility$ get; $setteraccessibility$ set;
Comments
Post a Comment