?
Solved

How would you translate VB.Net code into C# for a couple of statements?

Posted on 2016-10-21
5
Medium Priority
?
63 Views
Last Modified: 2016-10-25
Could you show me the C# equivalent of the following VB.Net code except that I want to read the content into a string and not a textbox:

Dim mystreamreader As New StreamReader(LocalFileName, Encoding.Default)
MyEditTextBox.Text = mystreamreader.ReadToEnd()
Debug.Print(mystreamreader.CurrentEncoding.CodePage)
mystreamreader.Close()
0
Comment
Question by:zimmer9
  • 2
4 Comments
 
LVL 64

Accepted Solution

by:
Fernando Soto earned 2000 total points
ID: 41854763
Try this code.

StreamReader mystreamreader = new StreamReader(LocalFileName, Encoding.Default);
string strFromStream = mystreamreader.ReadToEnd();
Debug.Print(mystreamreader.CurrentEncoding.CodePage);
mystreamreader.Close();
0
 
LVL 20

Expert Comment

by:Russ Suter
ID: 41854764
StreamReader mystreamreader = new StreamReader(LocalFileName, Encoding.Default);
MyEditTextBox.Text = mystreamreader.ReadToEnd();
Debug.Print(mystreamreader.CurrentEncoding.CodePage);
mystreamreader.Close();

Open in new window

And use this helpful tool for all your conversion needs:
http://converter.telerik.com/
0
 

Author Comment

by:zimmer9
ID: 41854766
How can I undo my response?
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 41854767
On your original post bottom right click on Request Attention and state that you want the question to be reopened.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question