iostreams?

This is a discussion on iostreams? within the C# Programming forums, part of the General Programming Boards category; Is there an equivalent of << and/or >> operators for C#? I just need something easy to use to convert ...

  1. #1
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853

    iostreams?

    Is there an equivalent of << and/or >> operators for C#?
    I just need something easy to use to convert everything to strings. It is really not nice using Convert.ToString(). I don't see the reason by the way why somethings cannot be overloaded, like make MessageBox.Show(int i), MessageBox.Show(string str), MessageBox.Show(DateTime dt) etc etc

  2. #2
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    All the integral types such as int are overloaded with toString() to display what you want.

    so MessageBox.Show(i.toString());

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    ToString() is automatically called for each type when concatenating strings:
    Code:
    int i = 12;
    float f = 3.4f;
    double d = 5.6;
    decimal dm = 7.8M;
    System.DateTime dt = System.DateTime.Now;
    
    System.Windows.Forms.MessageBox.Show("int: " + i + ", float: " + f  +", double: " + d  +", decimal: " + dm + ", datetime: " + dt);
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  4. #4
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    lol, I knew there was a simple solution...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. boost iostreams is_open()
    By l2u in forum C++ Programming
    Replies: 0
    Last Post: 02-21-2008, 10:00 AM
  2. building boost iostreams
    By l2u in forum C++ Programming
    Replies: 3
    Last Post: 04-14-2007, 03:29 PM
  3. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-24-2004, 12:22 AM
  4. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 08:26 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 04:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21