Results 1 to 2 of 2

Thread: Update DateTime

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Posts
    97

    Update DateTime

    Hello Everybody,
    I have created a multithreaded client server application. Whenever the client logs in a time stamp is created and added to the hashtable. Now I wanted to update the time in Seconds and also the hashtable when evenever a new client logs on to the server.
    My problem is how do I update the time and also the hashtable simultaneously.

    Pls guide..

    Rahil


    DateTime now= DateTime.Now;
    second= (now.Hour*60*60)+(now.Minute*60)+now.Second;
    usertimetable.Add(realId,second);
    currenttime=(int)usertimetable[realId];

  2. #2
    Lively Member Bolerophone's Avatar
    Join Date
    Dec 2003
    Location
    Himalayas
    Posts
    123
    Try this. I found this in MSDN. Hope it helps.



    Code:
    using System;
    using System.Collections;
    public class SamplesHashtable  {
    
       public static void Main()  {
    
          // Creates and initializes a new Hashtable.
          Hashtable myHT = new Hashtable();
          myHT.Add( "one", "The" );
          myHT.Add( "two", "quick" );
          myHT.Add( "three", "brown" );
          myHT.Add( "four", "fox" );
    
          // Displays the Hashtable.
          Console.WriteLine( "The Hashtable contains the following:" );
          PrintKeysAndValues( myHT );
       }
    
    
       public static void PrintKeysAndValues( Hashtable myList )  {
          IDictionaryEnumerator myEnumerator = myList.GetEnumerator();
          Console.WriteLine( "\t-KEY-\t-VALUE-" );
          while ( myEnumerator.MoveNext() )
             Console.WriteLine( "\t{0}:\t{1}", myEnumerator.Key, myEnumerator.Value );
          Console.WriteLine();
       }
    }
    /* 
    This code produces the following output.
    
    The Hashtable contains the following:
        -KEY-    -VALUE-
        three:    brown
        four:    fox
        two:    quick
        one:    The
    */

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width