class Program
    {
        static int localVariable = 0;

        static int PropertyOne
        {
            get { return localVariable; }
        }

        static void set_PropertyOne(int newValue)
        {
            localVariable = newValue;
        }

        static void Main(string[] args)
        {
        }
    }


**Error: already defines a member called 'set_PropertyOne' with the same parameter type**

please give me reason why is this happening. i dont need solution i need a reason for this error

regards
gemini

Recommended Answers

All 3 Replies

Well, I am not really sure about the reason, but I see it this way:
I suspect that the declaration of a dynamic property defines a set method that has the name set_propertyName. And as you are trying to create a method that has the exaclty same name it gives the error. AS I said it is how I see it, and I AM MOST PROBABLY wrong because Im not really well aware of how things work. I am a total newbie.
That is only the explanation i can think of, I dont want to mislead you. I am actually interested in finding the answer too. :)

thanks ... most probably... i am also of the same view !!!

I got the answer "the compiler breaks the code by itself in to two chunks; set_methodname and get_methodname in this case "set_PropertyOne"." so compiler gives error for already defined member....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.