Solved

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

Posted on 2016-10-21
5
41 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
5 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 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 63

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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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