C# C# Passing color into a method.

  • Thread starter Thread starter kiwijoey
  • Start date Start date
  • Tags Tags
    Color Method
Click For Summary
To pass a color into a C# method and create a new pen using that color, the method should be defined as MethodName(Color color). Inside the method, a new Pen can be instantiated using the provided color with the syntax: Graphics pen1 = new Pen(color, 1);. This approach effectively utilizes the Color object to create a pen with the specified color and a width of 1. The discussion confirms that this method definition and implementation are correct for achieving the desired outcome.
kiwijoey
Messages
2
Reaction score
0
How would you go about passing a color into a C# method and using that color inside the method to create a new pen? Assuming everything else is defined

Is it MethodName(Color color)
Graphics pen1 = new Pen(color.Color,1);



or is it something completely different?
 
Technology news on Phys.org
that should do it
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 0 ·
Replies
0
Views
1K
  • · Replies 19 ·
Replies
19
Views
943
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 27 ·
Replies
27
Views
6K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
18
Views
2K
Replies
9
Views
3K
  • · Replies 17 ·
Replies
17
Views
2K
  • · Replies 40 ·
2
Replies
40
Views
3K
Replies
17
Views
2K