Solved

I need C# converted to VB.net

Posted on 2016-10-14
1
79 Views
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);
    }
    else
    {
        Console.WriteLine("Token: {0}", reader.TokenType);
    }
}

Open in new window


Thanks in advance,
mrotor
0
Comment
Question by:mainrotor
[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
1 Comment
 
LVL 20

Accepted Solution

by:
Russ Suter earned 500 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)
            Else
                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.
1

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

724 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