If your requirement is to set the endpoint address through code instead of setting it in the config file, you can do it like this,
ServiceReference.Service service = new ServiceReference.Service();
service.Endpoint.Address = new EndpointAddress("http://localhost/MyServiceTest/Service.asmx");