Possible Duplicate:
Structure Vs Class in C#
Sorry if this is a open ended question, but I just want to know if my struct is too big. The reason why i want to use a struct is because I've learned that they're faster then classes and I really need the speed, I think.
I found out that if your struct is too big it actually slows down your program, so I want to know whats the guideline on this and whether or not my struct needs to be converted to a class or not.
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 = temp;
float[][] ptsTemp ={
new float[] {1, 0, 0, 0, 0},
new float[] {0, 1, 0, 0, 0},
new float[] {0, 0, 1, 0, 0},
new float[] {0, 0, 0, .9f, 0},
new float[] {0, 0, 0, 0, 1}};
ptsArray = ptsTemp;
clrMatrix = new ColorMatrix(ptsArray);
currentPic = The_Great_Find__Dig_Deeper.Properties.Resources.darknessflashlight;
}
public void setTransperancy(float value)
{
clrMatrix.Matrix33 = value;
}
public void drawRect(Graphics g)
{
imgAttr.SetColorMatrix(clrMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
g.DrawImage(currentPic, rect, 0, 0, currentPic.Width, currentPic.Height, GraphicsUnit.Pixel, imgAttr);
}
bool blackened
{
get;
set;
}
}
Should I change it to a class? It's getting kinda bloated to me. I'm using Visual Studio 2008.