C#으로 프로그래밍 된 WPF 클라이언트가 있습니다. 이 프로그램은 등록 데모이며, 이름을 입력하고 여기에 있는지 여부를 말한 다음 사용자가 텍스트 상자에 입력 한 서버와 포트로 보냅니다.오류 : "비 정적 필드, 메서드 또는 속성에 개체 참조가 필요합니다 ..."
그러나 이것을 코드에 적용하려고하면 "비 정적 필드, 메서드 또는 속성에 개체 참조가 필요합니다 ..."오류가 발생합니다. 이 당신이 그것을에 MainWindow
의 비 정적 멤버에 액세스 할 수 있도록하려면
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?
}
}
*/
}
}
}
그는 다음을 읽으려면 시간 초과했습니다. [질문하는 방법] – MethodMan
변경 내용은 충분히 만족 스럽습니다. 감사합니다. – HJagger95