TimeSpan.ToString C# (CSharp) Метод

ToString() публичный Метод

public ToString ( ) : String
Результат String
    public override String ToString()
    {
        return result;
    }

Usage Example

 public virtual bool runTest()
   {
   int iCountErrors = 0;
   int iCountTestcases = 0;
   Console.Error.WriteLine( strName + ": " + strTest + " runTest started..." );
   TimeSpan	ts;
   String		strDefTime = "00:00:00";
   long[]		lTicks = { 0L, 10000L, 1000*10000L, -1 };
   String[]	strResults =
   {
     "00:00:00",
     "00:00:00.0010000",
     "00:00:01",
     "-00:00:00.0000001",
   };
   do
     {
     Console.Error.WriteLine( "[]  Construct and verify TimeSpan objects" );
     try
       {
       for ( int ii = 0; ii < lTicks.Length; ++ii )
	 {
	 ++iCountTestcases;
	 ts = new TimeSpan( lTicks[ii] );
	 if ( String.Equals( ts.ToString(), strResults[ii] ) != true )
	   {
	   String strInfo = strTest + " error: ";
	   strInfo = strInfo + "Expected TimeSpan string <" + strResults[ii] + "> ";
	   strInfo = strInfo + "Returned TimeSpan string <" + ts.ToString() + "> ";
	   Console.WriteLine( strTest+ "E_101b: " + strInfo );
	   ++iCountErrors;
	   break;
	   }
	 }
       }
     catch (Exception ex)
       {
       Console.WriteLine( strTest+ "E_10001: Unexpected Exception: " + ex.ToString() );
       ++iCountErrors;
       break;
       }
     }
   while ( false );
   Console.Error.Write( strName );
   Console.Error.Write( ": " );
   if ( iCountErrors == 0 )
     {
     Console.Error.WriteLine( strTest + " iCountTestcases==" + iCountTestcases + " paSs" );
     return true;
     }
   else
     {
     System.String strFailMsg = null;
     Console.WriteLine( strTest+ strPath );
     Console.WriteLine( strTest+ "FAiL" );
     Console.Error.WriteLine( strTest + " iCountErrors==" + iCountErrors );
     return false;
     }
   }
All Usage Examples Of TimeSpan::ToString