ToString() public method

Converts the value to a System.String.
public ToString ( ) : string
return string
コード例 #1
0
		public void Rational2 ()
		{
			Rational r2 = new Rational (48, 18);

			Assert.AreEqual (48, r2.Numerator);
			Assert.AreEqual (18, r2.Denominator);
			Assert.AreEqual (48.0d/18.0d, (double) r2);
			Assert.AreEqual ("8/3", r2.ToString ());

			Assert.AreEqual (8, r2.Reduce ().Numerator);
			Assert.AreEqual (3, r2.Reduce ().Denominator);
		}
コード例 #2
0
		public void Rational3 ()
		{
			Rational r3 = new Rational (0, 17);

			Assert.AreEqual (0, r3.Numerator);
			Assert.AreEqual (17, r3.Denominator);
			Assert.AreEqual (0.0d/17.0d, (double) r3);
			Assert.AreEqual ("0/1", r3.ToString ());

			Assert.AreEqual (0, r3.Reduce ().Numerator);
			Assert.AreEqual (1, r3.Reduce ().Denominator);
		}
コード例 #3
0
		public void Rational1 ()
		{
			Rational r1 = new Rational (5, 3);

			Assert.AreEqual (5, r1.Numerator);
			Assert.AreEqual (3, r1.Denominator);
			Assert.AreEqual (5.0d/3.0d, (double) r1);
			Assert.AreEqual ("5/3", r1.ToString ());

			Assert.AreEqual (5, r1.Reduce ().Numerator);
			Assert.AreEqual (3, r1.Reduce ().Denominator);
		}