You get this error because you have put this method in a namespace and not in a class..
using System;
namespace yourNameSpace
{
class yourClass
{
public Address GetAdr(int id)
{
Address ad = new Address();
adrt.Connection.ConnectionString = con;
adrt.Connection.Open();
ad.City = adrt.Connection.State.ToString();
return ad;
}
}
}
Please follow this sequence then check it out..!