Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Host asp.net pages 5 26
Close tabpage of custom control 9 24
Wav problem 4 19
Windows Media Player 2 18
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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

23 Experts available now in Live!

Get 1:1 Help Now