如何调用静态方法?我想从我创建的类中调用它,我想通过IP获取位置。我已经声明了它,但我需要做的是调用这个方法...作为
说实话,我在这里很困惑,我需要实例化
到目前为止,我已经做到了这一点;
static
...说实话,我在这里很困惑,我需要实例化
address
、city
等吗?到目前为止,我已经做到了这一点;
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();
}
}
}
}