Home > front end >  using csvhelper writer with shouldquote in vb.net
using csvhelper writer with shouldquote in vb.net

Time:09-25

I can see how shouldquote works with c# but does anyone have an example in vb.net?

I need to wrap every field with chr(34)

CodePudding user response:

Private Sub Main()
    Dim records = New List(Of Foo) From {
        New Foo With {
            .Id = 1,
            .Name = "one"
        }
    }
    
    Dim config = New CsvConfiguration(CultureInfo.InvariantCulture) With {
        .ShouldQuote = Function(args) True 
    }

    Using csv = New CsvWriter(Console.Out, config)
        csv.WriteRecords(records)
    End Using
    
End Sub

Public Class Foo
    Public Property Id As Integer
    Public Property Name As String
End Class
  • Related