How to call each other between the two classes of C-sharp website App_code

clipboard.png
what should I do if I want to call the method of f.cs in GoalModel.ashx.cs?
GoalModel.ashx.cs

namespace KeyGoal
{
    public class GoalModel : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            string t = HttpContext.Current.Request.Form["t"];

            switch (t)
            {
                case "1":
                    GetInfo();
                    break;
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
        public string GetInfo()
        {
            //sqlselect 
            try
            {
                string sql = "select * from goal";
                DataTable dt = MySQLHelper.QuerySql(sql);
                string json = f.ToString(dt);
                json = json.Replace("\"", "\\\"");
                context.Response.Write("{\"status\":\"" + json + "\"}");
            }
            catch (Exception e)
            {
                throw e;
            }


        }

    }
}

f.cs

namespace KeyGoal
{
    public static class f
    {

public static string ToJson(this DataTable dt)
        {
            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

            javaScriptSerializer.MaxJsonLength = Int32.MaxValue; //
            ArrayList arrayList = new ArrayList();
            foreach (DataRow dataRow in dt.Rows)
            {
                Dictionary<string, object> dictionary = new Dictionary<string, object>();  //
                foreach (DataColumn dataColumn in dt.Columns)
                {
                    dictionary.Add(dataColumn.ColumnName, dataRow[dataColumn.ColumnName].ToString());
                }
                arrayList.Add(dictionary); //ArrayList
            }

            return "{root:" + javaScriptSerializer.Serialize(arrayList) + "}";  //json
        }
        
        
Jun.25,2022

extend the method. Under the same namespace, the object can be called directly.

  extension method  

Menu