I have a non-static class in which i have several properties, ie serverURL, serverPort etc, and the class has a constructor. The constructor accepts arguments which it then uses to 'set' the properties, initialising them. Here is the code:
public Server(string newServerAddress, int newServerPort) {
serverAddress = newServerAddress;
serverPort = newServerPort;
}
public string serverAddress {
get {
return serverAddress;
}
set {
serverAddress = value;
}
}
public int serverPort {
get {
return serverPort;
}
set {
serverPort = value;
}
For some reason this gives me a stack overflow error, and I have no idea why. Here is the code being used to call it:
Server test = new Server("server.url.here",8080);
This code is obviously bound by a class, but I left it out here. This is an amateur problem, and I've done things like this before but I'm completely bewildered by what is going on, and when I try and debug it in visual studio, it tells me that it can't debug it, presumably since it's using the stack to debug.