0

hi :)
This is my code:

public static void ChangeColor(string myObject, string myColor)
        {
            myObject.ForeColor = Color.myColor; //This doesnt work, why?
        } 

private void button1_Click(object sender, EventArgs e)
        {
            ChangeColor("Programming", "PowderBlue");
        }

"Programming" is a label

I've written many programs in VB but i'm new to C# so I don't really know how it works :S

Thanks in advance!

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by serkan sendur
0

try this

public static void ChangeColor(Label myObject, Color myColor)
        {
            myObject.ForeColor = myColor; 
        } 

        private void button1_Click(object sender, EventArgs e)
        {
            ChangeColor(label1, Color.PowderBlue);
             
        }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.