I have a WPF client programmed with c#. The program is a register demo, you type a name and say if they are here or not and send it to a server and port that is entered into a textbox by the user.
When trying to apply this in the code however, I get the error: “an object reference is required for the non-static field, method or property…”. This is on the "client.connect" line...
namespace client
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public class connectandsend
{
//if 'REGISTER' button clicked do this...{
static void connect()
{
TcpClient client = new TcpClient(); // New instance of TcpClient class of the .Net.Sockets
client.Connect(server_txt.Text, Convert.ToInt32(port_txt.Text)); // Server, Port
StreamWriter sw = new StreamWriter(client.GetStream()); // New StreamWriter instance
StreamReader sr = new StreamReader(client.GetStream()); // New StreamReader instance
}
/* static void send()
{
stream write... name.text and 'here' or 'not here' ticked box?
}
}
*/
}
}
}