Why Do I Get a Compile Error Here?

From: C# Learner (csharp_at_learner.here)
Date: 05/24/04


Date: Mon, 24 May 2004 22:09:32 +0100

My class has a member variable declared as:

     string address;

Here is a method of my class:

    /// <remarks>
    /// This is run in a seperate thread.
    /// </remarks>
    void DoListen()
    {
1: listener = new TcpListener(IPAddress.Parse(address), port);
2: listener.Start();
3: for (;;) {
4: Socket client = listener.AcceptSocket();
5: string address = (client.RemoteEndPoint as IPEndPoint).Address.ToString();
6: Connection connection = new Connection(client);
7: }
    }

I get a compile error on line 5:

"A local variable named 'address' cannot be declared in this scope because it would
give a different meaning to 'address', which is already used in a 'parent or
current' scope to denote something else"

Am I missing something, or have I encountered a C# compiler bug?



Relevant Pages

  • local module scopes and name spaces
    ... that I have a new scope and that this scope has 2 name spaces - the ... module's port name space because of the port ... module's module name space because of the net declarations? ... The connection can be unidirectional (either ...
    (comp.lang.verilog)
  • Re: biztalk lag time
    ... the send port to determine if a message was transmitted successfully. ... Put the send shape inside a scope ... Set the send port "delivery notification" property to "transmitted" ... If transmission fails, whatever you put in the exception handler will run. ...
    (microsoft.public.biztalk.general)
  • Re: Serial port
    ... >>the serial port. ... Why I cannot see on my scope the data signal if I put ... > Connect your scope ground to SIGNAL GROUND in the serial port ... select the setup options, and 'advanced', and set 'flow control', to ...
    (sci.electronics.design)
  • Connecting SCT to desktop
    ... It houses a Schmidt-Cassegrain telescope with a wedge and permanent mount. ... the scope connected to a laptop using the serial port to run the scope and the parallel port for the web cam. ...
    (sci.astro.amateur)
  • Re: Serial port
    ... > After my question on the parallel port, I must ask you something about ... > the serial port. ... Why I cannot see on my scope the data signal if I put ...
    (sci.electronics.design)