Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6074705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:24:43+00:00 2026-05-23T10:24:43+00:00

So TextReader.ReadLine() returns a string, but TextReader.Read() returns an int value. This int value

  • 0

So TextReader.ReadLine() returns a string, but TextReader.Read() returns an int value. This int value also seems to be in some sort of format that I don’t recognize. Is it possible to convert this integer to a character? Thanks for any help.

EDIT:

TextReader Values = new StreamReader(@”txt”);

    string SValue1;
    int Value1;       
    Value1 = Values.Read();        
    Console.WriteLine(Value1);
    Console.ReadKey();

When it reads out the value it gives me 51 as the output. The first character in the txt file is 3. Why does it do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:24:44+00:00Added an answer on May 23, 2026 at 10:24 am

    According to the documentation for the StringReader class (a sub-class of TextReader), the return value of Read() can be converted to a char, but you need to check if you’re at the end of file/string first (by checking for -1). For example, in this modified code from the documentation:

    while (true)
    {
        int integer = stringReader.Read();
    
        // Check for the end of the string before converting to a character.
        if (integer == -1)
            break;
    
        char character = (char) integer; // CONVERT TO CHAR HERE
    
        // do stuff with character...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sure this is something very simple that I'm screwing up, but here goes:
I have a string which I read in from : TextReader tr = new
Is there a way to know that a call to TextReader.Read or TextReader.ReadToEnd call
I am using a Socket to receive data via TCP, and TextReader.ReadLine to read
i need to read files that look like this into a datatable: A02 BLANK031
Currently, this is how I'm opening a file to read it: using (TextReader reader
private void sessionText() { try { System.IO.TextReader r = new System.IO.StreamReader(saved.txt); this.textBox1.Text = r.ReadLine();
This is my solved program that will read a text file with delimiters and
So I have this foreign namebank in a textfile that I read from and
I want to run a background task that reads input from a TextReader and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.