In F#, I am trying to write a class that has a constructor which calls a method and assigns the returned value to a property. Currently I can't get it to compile. This is my F# code:
namespace Model
type MyClass() =
do
MyProperty <- GenerateString()
member val public MyProperty = ""
with get, set
member public this.GenerateString() =
"this is a string"
The compile error is: FS0039 The value or constructor MyProperty is not defined.
What can I do to fix this?
I have pasted some C# code to demonstrate what I'm trying to do:
public class MyClass
{
public string MyProperty { get; set; }
public MyClass()
{
MyProperty = GenerateString();
}
private string GenerateString()
{
return "this is a string";
}
}