我正在f#中做一个名为"2D形状编辑器"的项目.我之前在c#中完成了这个项目,所以我已经掌握了如何连接两个形状的所有逻辑.所以我知道我需要一个列表来保存我将要添加的所有形状.但我根本无法让我的addToList方法起作用.
我的ShapeList:
let mutable ShapeList:List<RectangleZ> = [RectangleZ(100,100)]
Run Code Online (Sandbox Code Playgroud)
我的添加方法:
let addToList (listan:List<RectangleZ>) (element:RectangleZ) = let ShapeList = ShapeList@[element] in ShapeList
//Method to add into the ShapeList
let addToList (listan:List<RectangleZ>) (element:RectangleZ) = element::ShapeList
//Other try on adding into shapeList
Run Code Online (Sandbox Code Playgroud)
应该向ShapeList添加矩形的按钮:
btn.Click.Add(fun _ -> new RectangleZ(500, 100) |> addToList ShapeList |>ignore |> saver)
//Button click method that should be adding the RectangleZ(500, 100) to my ShapeList
Run Code Online (Sandbox Code Playgroud)
当然我的矩形:
type RectangleZ(x:int, y:int)=
let mutable thisx = x
let mutable thisy = y
let mutable thiswidth …Run Code Online (Sandbox Code Playgroud) 我正在为windows phone制作一个单元转换器,但是我遇到了类继承的一些问题.
我有一个类Measurement应该是我程序中图形内容的顶级类.
public class Measurement : PhoneApplicationPage
{
public void Convert(object give)
{
supervar.Comparer(this);
}
public WindowsPhoneControinput supervar { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
Measurement不包含任何图形内容,但它的子类做; 这是我遇到困难的地方.
子类:Lengthco,Weigthco并且Volumeco需要继承,Measurement但编译器说:
"Partial declarations declarations of 'Phoneapp1.Lengthco' Must not specify different base classes".
Run Code Online (Sandbox Code Playgroud)
为什么会这样?