我知道在C#中我可以創建一個工廠,但我不知道如何在aspx中重用代碼。我的代碼最初只針對ARList,但現在有了IcnList。我想過要做一個switch語句,但是沒有更好的代碼呢?如何編碼重用apsx?
的功能
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ARExtractionController arController = new ARExtractionController();
Dictionary<int, string> ARDictionary = arController.GetTickets();
List<int> sortedARList = new List<int>();
foreach (KeyValuePair<int, string> kv in ARDictionary)
{
sortedARList.Add(kv.Key);
}
sortedARList.Sort();
sortedARList.Reverse();
ARList.DataSource = sortedARList;
ARList.DataBind();
ARList.Items.Insert(0, " ");
ARList.AutoPostBack = true;
}
}
可能重複[如何重用此C#代碼?](http://stackoverflow.com/questions/6115926/how-to-reuse-this-c-sharp-code) – tomfanning