可能重复:
C#中的结构与类
很抱歉,如果这是一个开放式问题,但我只是想知道我的结构是否太大了.我想要使用结构的原因是因为我已经知道它们比类更快,我认为我真的需要速度.
我发现如果你的结构太大,它实际上会减慢你的程序,所以我想知道这个指南是什么以及我的结构是否需要转换为类.
public struct Tiles
{
public Rectangle rect;
//i know this wont run with them being initalized like this but if i change to a class this will
//stay like this and im in the middle of deciding what to do
Bitmap currentPic = new Bitmap(50, 50);
ImageAttributes imgAttr = new ImageAttributes();
float[][] ptsArray;
ColorMatrix clrMatrix;
public void setTiles(int i, int k, int width, int height)
{
Rectangle temp = new Rectangle(i, k, width, height);
rect = …Run Code Online (Sandbox Code Playgroud) 嗨,我只是想知道是否有一种方法给班级自己的点击事件.例如,我有一个卡类,有没有办法知道用户何时点击该类的矩形(显示卡的图片)?
或者更好的是,我如何知道何时点击卡片矩形?