Solved

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

Posted on 2016-10-21
5
31 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 62

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 62

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now