public void AddEdge() { string routerOne = mainConsole.ChooseRouter(); string routerTwo = mainConsole.ChooseRouter(); Router routOne = null, routTwo = null; foreach (var a in MainNetwork.routers) { if (a.Id == routerOne) { routOne = a; } if (a.Id == routerTwo) { routTwo = a; } } if (routOne != null && routTwo != null) { routOne.AddEdge(routTwo); } }