本文介绍了如何使标签显示像数字计数器动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在开发一个幸运系统的项目,但我不知道如何使标签显示像数字计数器动画。标签是来自文本文件的员工ID。下面是我的代码。 我尝试了什么: public partial class _Default:System.Web.UI.Page { private Random random = new Random(); private string testFilePath = @ C:\\TestFile.txt; private 列表< string> testFileLines; 受保护 void Page_Load( object sender,EventArgs e) { if (!File.Exists(testFilePath)) { Response。写($ 该文件不存在:{testFilePath}); } 其他 { 尝试 { testFileLines = File.ReadAllLines(testFilePath).ToList(); } catch (例外情况) { Response.Write($ 无法读取文件{testFilePath}。异常详情:{ex}); } } } 受保护 void Button1_Click( object sender,EventArgs e) { if ( testFileLines!= null && testFileLines.Count > 0 ) { var randomLine = testFileLines [random.Next(testFileLines.Count)]; Label1.Text = randomLine; testFileLines.Remove(randomLine); } } } 解决方案 无法读取文件{testFilePath}。异常详情:{ex}); } } } 受保护 void Button1_Click( object sender,EventArgs e) { if ( testFileLines!= null && testFileLines.Count > 0 ) { var randomLine = testFileLines [random.Next(testFileLines.Count)]; Label1.Text = randomLine; testFileLines.Remove(randomLine); } } } I'm developing a project that is lucky system,but i don't know how to make label display like number counter animation. The label is employee id from text file.Below are my code.What I have tried:public partial class _Default : System.Web.UI.Page{ private Random random = new Random(); private string testFilePath = @"C:\\TestFile.txt"; private List<string> testFileLines; protected void Page_Load(object sender, EventArgs e) { if (!File.Exists(testFilePath)) { Response.Write($"The file does not exist: {testFilePath}"); } else { try { testFileLines = File.ReadAllLines(testFilePath).ToList(); } catch (Exception ex) { Response.Write($"Could not read file {testFilePath}. Exception details: {ex}"); } } } protected void Button1_Click(object sender, EventArgs e) { if (testFileLines != null && testFileLines.Count > 0) { var randomLine = testFileLines[random.Next(testFileLines.Count)]; Label1.Text = randomLine; testFileLines.Remove(randomLine); } }} 解决方案 这篇关于如何使标签显示像数字计数器动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-29 16:45