Solved

I need C# converted to VB.net

Posted on 2016-10-14
1
66 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
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

772 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