में एक स्टेटिक विधि को कॉल करना मैं एक स्थिर विधि कैसे कॉल करूं? मैं इसे एक वर्ग से कॉल करना चाहता हूं, मैं आईपी से स्थान प्राप्त करना चाहता हूं। मैं इसे घोषित किया है, लेकिन मैं क्या करने की जरूरत है विधि कॉल ... 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();
}
}
}
}
आपने क्या प्रयास किया? बस LocationTools.GetLocationFromIP (...) का उपयोग करें; –