【发布时间】:2017-01-27 19:18:04
【问题描述】:
我有一个用 c# 编写的 WPF 客户端。该程序是一个注册演示程序,您输入一个名称并说出他们是否在这里,然后将其发送到服务器和端口,由用户输入到文本框中。
但是,当尝试在代码中应用它时,我收到错误消息:“非静态字段、方法或属性需要对象引用……”。 这是在“client.connect”行...
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?
}
}
*/
}
}
}
【问题讨论】:
-
做了修改,希望够用,谢谢。
标签: c# wpf object-reference