Posted on: 9/3/2015 6:42:02 PM | Views : 776

When should I use a function versus a class? 
I have the function below that I plan to copy into a class. Would you recommend keeping as a function? I need multiple values from the function and may need to access them throughout the application with code that is easy to follow. Advice please
Function
private int GetIPLocation() { string hostname = Dns.GetHostName(); //get IP (SubString will trim IP address (10.242.12.111) TO FIRST 6 characters that are in the database string LocationIP = Dns.GetHostByName(hostname).AddressList[0].ToString().Substring(0, 6); string ConnString = ConfigurationManager.ConnectionStrings["VTrackingConnectionString"].ConnectionString; using (SqlConnection con = new SqlConnection(ConnString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = co ...

Go to the complete details ...