Why Do I Get a Compile Error Here?
From: C# Learner (csharp_at_learner.here)
Date: 05/24/04
- Next message: Andy Gaskell: "Re: Cannot Refer to DropDownList Items by Index"
- Previous message: Niki Estner: "Re: finding opened window based on its handle ( C# )"
- Next in thread: C# Learner: "Re: Why Do I Get a Compile Error Here?"
- Reply: C# Learner: "Re: Why Do I Get a Compile Error Here?"
- Reply: John J. Hughes II: "Re: Why Do I Get a Compile Error Here?"
- Messages sorted by: [ date ] [ thread ]
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?
- Next message: Andy Gaskell: "Re: Cannot Refer to DropDownList Items by Index"
- Previous message: Niki Estner: "Re: finding opened window based on its handle ( C# )"
- Next in thread: C# Learner: "Re: Why Do I Get a Compile Error Here?"
- Reply: C# Learner: "Re: Why Do I Get a Compile Error Here?"
- Reply: John J. Hughes II: "Re: Why Do I Get a Compile Error Here?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|