I need C# converted to VB.net

Posted on 2016-10-14
Medium Priority
Last Modified: 2016-10-19
Hi Experts,
I need the code below converted from C# to vb.net.

Already tried all the conversion website, and have not been successful.

JsonTextReader reader = new JsonTextReader(new StringReader(json));
while (reader.Read())
    if (reader.Value != null)
        Console.WriteLine("Token: {0}, Value: {1}", reader.TokenType, reader.Value);
        Console.WriteLine("Token: {0}", reader.TokenType);

Open in new window

Thanks in advance,
Question by:mainrotor
1 Comment
LVL 20

Accepted Solution

Russ Suter earned 2000 total points
ID: 41844436
Not sure where JsonTextReader is coming from (don't know the Imports location or reference) but this should work...
        Dim reader As New JsonTextReader(New StringReader(json))
        While reader.Read()
            If reader.Value IsNot Nothing Then
                Console.WriteLine("Token: {0}, Value: {1}", reader.TokenType, reader.Value)
                Console.WriteLine("Token: {0}", reader.TokenType)
            End If
        End While

Open in new window

EDIT: I'm assuming the JsonTextReader is coming from the Newtonsoft.Json package and that the variable json is just a string declared elsewhere. The above sample compiles just fine but without knowing the contents of json I can't say whether or not it produces the results you expect.

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Native ability to set a user account password via AD GPO was removed because the passwords can be easily decrypted by any authenticated user in the domain. Microsoft recommends LAPS as a replacement and I have written an article that does something …
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Through the video, you can check the migration process of Outlook PST file to PDF. Kernel for Outlook to PDF tool can convert Outlook emails with all attributes like Subject, To, From, Cc, Bcc and other folders such as Inbox, Outbox, Sent Items, Jun…
Suggested Courses

619 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