Thread: ReadLine to int

  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 08: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, 08: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-02-2003, 12:26 AM
  5. easy if you know how to use functions...
    By Unregistered in forum C Programming
    Replies: 7
    Last Post: 01-31-2002, 07:34 AM