c# 6.0 - Unable to use primary constructor parameter -


i playing new features of c# 6.0
i have following line of code

public class circle(int radius) {     public double circumference => 2 * 3.14 * radius; } 

above code doesn't work , gives error "the name radius doesn't exist in current context"

but when use

public class circle(int radius) {     int radius = radius;     public double circumference => 2 * 3.14 * radius; } 

code works fine.
sort of bug vs ctp or wrong code. believe should able use parameter of primary constructor inside constructor whithout setting other variable.

well, may doesn't answer question directly primary constructor has been withdrawn c# 6.0.

see: changes language feature set , question: primary constructors no longer compile in vs2015

you trying code in visual studio 2014 ctp. need download , install new version of visual studio 2015 preview. (but first have un-install visual studio 2014 ctp)

you may see latest: languages features in c# 6 , vb 14


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -