Reputation: 770
I am trying to create a TcpClient and having problems with the constructor...
public class TcpClient : IDisposable
{
static void Connect(String server, String message)
{
try
{
// Create a TcpClient.
// Note, for this client to work you need to have a TcpServer
// connected to the same address as specified by the server, port
// combination.
Int32 port = 9000;
TcpClient client = new TcpClient(server, port);
I get error:
Error 1 'TcpClient' does not contain a constructor that takes 2 arguments
My question:
why does this problem occurs & how to solve it?
Upvotes: 1
Views: 814
Reputation: 7105
This is because your class is named TcpClient which is the same name given to the class in the framework, as explained here. Just give your class a different name.
You can obviously also use the namespace to indicate to the compiler exactly which TcpClient class you are referring to, for example
new System.Net.Sockets.TcpClient.TcpClient(server, socket);
Upvotes: 3