ReadLine to int

This is a discussion on ReadLine to int within the C# Programming forums, part of the General Programming Boards category; Hello all, I'm in the process of trying to learn C# as with the continued Mono improvements it seems like ...

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    68

    ReadLine to int

    Hello all,

    I'm in the process of trying to learn C# as with the continued Mono improvements it seems like a good language to learn (having dabbled in ANSI C, C++, PHP etc for a while now).

    Anyway. I figured the best way to learn would be to try and write something useful. Part of that is readign & writing to a file. Writing is the easy part, However the value stored in the text file is an int, how can I read feed this into my application as an int as opposed to a string?

    As a point of reference, the relevant section of code is below.

    Code:
    	public int InstallDuration
    	{
    		get
    		{
    			TextReader ProdInfo		=	new StreamReader("ProdInfo.dat");
    			return ProdInfo.ReadLine();
    			ProdInfo.Close();
    		}
    		set
    		{
    			TextWriter ProdInfo		=	new StreamWriter("ProdInfo.dat");
    			ProdInfo.WriteLine(value);	
    			ProdInfo.Close();
    		}
    	}
    Any suggestions/links would be greatly appreciated
    Last edited by DaveHope; 01-21-2006 at 07:20 AM.

  2. #2
    Registered User
    Join Date
    Dec 2003
    Posts
    68
    No matter. Got off my lazy ass and did some research

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    2
    take a look in the System.ConverTo class

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Replies: 2
    Last Post: 03-24-2006, 07:36 PM
  3. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 05:20 AM
  4. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-01-2003, 11:26 PM
  5. easy if you know how to use functions...
    By Unregistered in forum C Programming
    Replies: 7
    Last Post: 01-31-2002, 06:34 AM

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