Как мне вызвать статический метод? Я хочу вызвать это из созданного мной класса, я хочу получить местоположение по IP. Я объявил об этом, но мне нужно вызвать метод ... как static
...
Если честно, я здесь совершенно запутался, нужно ли мне создавать экземпляр адрес
, город
и т. Д.?
Я уже сделал это;
LocationTools.cs
public static class LocationTools
{
public static void GetLocationFromIP(string address, out string city, out string region, out string country, out double? latitude, out double? longitude)
{
Home.cs
public string IPAPIKey
{
get
{
return WebConfigurationManager.AppSettings["IPAPIKey"];
}
}
////To get the ip address of the machine and not the proxy use the following code
static void GetLocationFromIP()
{
string strIPAddress = Request.UserHostAddress.ToString();
strIPAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (strIPAddress == null || strIPAddress == "")
{
strIPAddress = Request.ServerVariables["REMOTE_ADDR"].ToString();
}
}
}
}