faketicker.cs

来自「10个Visual C#.NET例子」· CS 代码 · 共 77 行

CS
77
字号
using System;
using System.Collections;

namespace Ticker
{
	/// <summary>
	///  FakeTicker class.
	/// </summary>
	public class FakeTicker : EventArgs
	{
		private string strName;
		private int nValue;
		private Random rand;

		/// <summary>
		/// The name of this ticker
		/// </summary>
		public string Name
		{
			get
			{
				return strName;
			}
			set
			{
				strName = value;
			}
		}

		/// <summary>
		///  The current value for this ticker
		/// </summary>
		private int Value
		{
			get
			{
				return nValue;
			}
			set
			{
				nValue = value;
			}
		}

		/// <summary>
		/// block the standard constructor
		/// </summary>
		private FakeTicker()
		{
		}

		/// <summary>
		/// public constructor
		/// </summary>
		/// <param name="sName">The Name for this FakeTicker</param>
		/// <param name="nCount">The Starting parameter for this FakeTicker</param>
		public FakeTicker( string sName, int nSeed )
		{
			rand = new Random( nSeed );
			Value = rand.Next();
			Name = sName;
		}


		/// <summary>
		///  Calculate the value for this ticker
		/// </summary>
		/// <returns>The next random value for this ticker</returns>
		public int Calculate()
		{
			return Value = rand.Next();
		}

	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?