Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

越少的自定义类越好,多使用系统的对象或者接口 #2

Open
linli8 opened this issue May 20, 2014 · 0 comments
Open

越少的自定义类越好,多使用系统的对象或者接口 #2

linli8 opened this issue May 20, 2014 · 0 comments

Comments

@linli8
Copy link
Owner

linli8 commented May 20, 2014

比如分页中的PageQueryResult,应该有更好的选择,如果只是为了传出数据总条数,可以使用List中的Capacity,或者继承List实现一个新类,但返回List,使用拓展方法获得总条数
比如:
class PageingList : List
{
public int TotalCount {get;set;}

}

static class ExtMethod
{
public int GetTotalCount(this List list)
{
if(list is PageingList)
{
return ((PageingList)list).TotalCount;
}else
{
return list.Count;
}
}
}

//分页方法中

public List Pageing(int size,int pageindex)
{
.....
return new PageingList (){ Total = 10000 };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant