我想在bmp图像上绘制一条线,该线在C#中使用drawline方法传递给方法
public void DrawLineInt(Bitmap bmp)
{
Pen blackPen = new Pen(Color.Black, 3);
int x1 = 100;
int y1 = 100;
int x2 = 500;
int y2 = 100;
// Draw line to screen.
e.Graphics.DrawLine(blackPen, x1, y1, x2, y2);
}
Run Code Online (Sandbox Code Playgroud)
这给了一个错误.所以我想知道如何在这里包含paint事件(PaintEventArgs e)
并且还想知道在调用drawmethod时如何传递参数?例
DrawLineInt(Bitmap bmp);
Run Code Online (Sandbox Code Playgroud)
这会产生以下错误"当前上下文中不存在名称'e'"
这段代码有什么问题?
addNum :: Int->Int-> Int
addNum a b = a+b
divideby :: ( Int->Int -> Int ) -> Int ->float
divideby f z = f /z
Run Code Online (Sandbox Code Playgroud)
我想将该addNum函数作为divideby带除数的输入,然后输出答案.因此该divideby函数应该充当更高阶函数.
这段代码有什么问题?它给出以下错误:
*** Expression : f / z
*** Term : f
*** Type : Int -> Int -> Int
*** Does not match : Int
Run Code Online (Sandbox Code Playgroud) 我想使用Haskell高阶函数Foldr来计算字符串的长度
stringlength = foldr (\_n -> 1 + n) 0
Run Code Online (Sandbox Code Playgroud)
它给出了以下错误.这段代码有什么问题?
Unresolved top-level overloading
*** Binding : stringlength
*** Outstanding context : (Num b, Num (b -> b))
Run Code Online (Sandbox Code Playgroud) 我想知道shift是否是更高阶函数.
chartoInt :: Char -> Int
chartoInt c = ord c
Inttochar :: Int -> Char
Inttochar n = chr n
shift :: Int -> Char -> Char
shift n c = Inttochar (chartoInt c + n)
Run Code Online (Sandbox Code Playgroud)