빈 생성자와 매개 변수를 허용하는 생성자 오버로드를 가져 와서 공용 속성에 할당하려고합니다. 내가 붙어 곳속성 지정이있는 f #의 다중 생성자
이있다 :`예기치 않은 키워드 '새로운'개체 표현 :
type TemplateService() =
interface ITemplateService with
//Properties
member TemplateDirectory = ""
//Constructors
new (templateDirectory:string) = //Error here.
if (templateDirectory == null) then
raise (new System.ArgumentNullException("templateDirectory"))
TemplateDirectory = templateDirectory;
그것은 나에게 오류를 제공합니다. '멤버', '오버라이드'또는 다른 토큰이 필요합니다.
This instance member needs a parameter to represent the object being invoked. Make the member static or use the notation 'member x.Member(args) = ...'
할당 전에 'd'가 null 또는 비어 있는지 확인하고 싶습니다. 앞에 오류가 발생하는 경우. –
null 확인을 위해 Daniel이 편집 한 버전을 참조하십시오. –
그러나 나는 단지 arguement를 받아들이는 생성자에 대해서만이 테스트를 할 필요가있다. 'new TemplateService()'를 실행하면 오류가 발생합니다. –