Skip to content

Instantly share code, notes, and snippets.

@ss22219
Last active December 24, 2015 22:29
Show Gist options
  • Save ss22219/6873573 to your computer and use it in GitHub Desktop.
Save ss22219/6873573 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
class Program
{
public static Page<int> page;
static void Main(string[] args)
{
Console.Write("请输入每页显示数量:");
int pageSize = int.Parse(Console.ReadLine());
Console.Write("请输入总数量:");
int totalCount = int.Parse(Console.ReadLine());
Console.Write("请输入页标数量:");
int lableCount = int.Parse(Console.ReadLine());
InitialPage(pageSize, totalCount, lableCount);
ShowLable();
while (true)
{
Console.Write("请输入页号:");
int pageIndex = int.Parse(Console.ReadLine());
Console.Clear();
ShowLable(pageIndex);
}
}
public static void InitialPage(int pageSize, int totalCount, int lableCount)
{
page = new Page<int>(new List<int>(), 1, pageSize,totalCount, lableCount);
}
public static void ShowLable(int pageIndex = 1)
{
page.PageIndex = pageIndex;
foreach (int lable in page.GetPageLabel())
{
if (lable == page.PageIndex)
Console.Write("[" + lable + "] ");
else
Console.Write(lable + " ");
}
Console.WriteLine();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment