Given colors, subtract the fade value and print

What is wrong with the following C# code? It should take the given colors and subtract the given fadeValue and then print out the new faded values. Please copy and paste the code into your response and fix it so that it works correctly.
using System;

namespace PCD
{
class MainClass
{
static void Main(string[] args)
{
int red=110;
int green=220;
int blue=230;

getFadedColor(red, green, blue, 10);
getFadedColor(red, green, blue, 20);

Console.WriteLine("red: " + red);
Console.WriteLine("green: " + green);
Console.WriteLine("blue: " + blue);
}

static void getFadedColor(int red, int green, int blue, int fadeValue)
{
red -= fadeValue;
green -= fadeValue;
blue -= fadeValue;
}
}
}

Questions by musclebai   answers by musclebai

Showing Answers 1 - 6 of 6 Answers

namespace PCD
{
class MainClass
{
static void Main(string[] args)
{
int red=110;
int green=220;
int blue=230;

  getFadedColor(ref red, ref  green, ref  blue, 10);
  getFadedColor(ref red, ref  green, ref  blue, 20);


Console.WriteLine("red: " + red);
Console.WriteLine("green: " + green);
Console.WriteLine("blue: " + blue);
}

       static void getFadedColor(ref int red,ref int green ,ref int blue , int fadeValue)
        {
            red -= fadeValue;
            green -= fadeValue;
            blue -= fadeValue;
        }
}
}

sajja.babu

  • Jan 8th, 2010
 

namespace PCD
{
    class MainClass
    {
        static void Main(string[] args)
        {
             int red = 110;
             int green = 220;
             int blue = 230;

            getFadedColor( red,  green,  blue, 10);
            getFadedColor( red,  green,  blue, 20);

            Console.WriteLine("red: " + Red);
            Console.WriteLine("green: " + Green);
            Console.WriteLine("blue: " + Blue);
        }

        static void getFadedColor( int red,  int green,  int blue,  int fadeValue)
        {
            red -= fadeValue;
            green -= fadeValue;
            blue -= fadeValue;

            _red = red;
            _green  = green;
            _blue = blue;

         }

        private static int _red;
        private static int _green;
        private static int _blue;

        public static int Red
        {
            get
            {
                return _red;
            }
        }

        public static int Green
        {
            get
            {
                return _green;
            }
        }

        public static int Blue
        {
            get
            {
                return _blue;
            }
        }      
    }
}

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions