Solved

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

Posted on 2016-10-21
5
45 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
parse string in c# 5 40
ComboBox to String Not Working 5 43
C#: How do I test for null objects and a dub a value? 2 37
vb.net searchandselect 12 15
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 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