C
C# Learner
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?
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?