Is there any difference between
Brush b = Brushes.Red;
and
Brush b = new SolidBrush(Color.Red);
Because when i use the first constructor i got an exception in drawing the line through the graphics,but it’s solved in the second one, i cant figure out the difference???
The first is not a constructor, it’s just getting one of the pre-created objects.
The second one is using the constructor, which means that you are responsible for the object and should dispose it when you are done with it. If you don’t dispose it, it will hog a window handle until the garbage collector collects it.
There should be no difference in usage other than that. If you get an exception, it’s most likely related to something else that you are doing.