小编use*_*071的帖子

如何在图像上画线?

我想在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'"

c# system.drawing

12
推荐指数
2
解决办法
5万
查看次数

Haskell更高阶函数需要帮助

这段代码有什么问题?

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 higher-order-functions

1
推荐指数
1
解决办法
244
查看次数

如何使用Haskell高阶函数foldr来计算字符串的长度

我想使用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)

haskell higher-order-functions

1
推荐指数
1
解决办法
744
查看次数

这是Haskell的高阶函数吗?

我想知道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)

haskell higher-order-functions

0
推荐指数
1
解决办法
352
查看次数