Parsing String into multiple variable length String (C#)

Posted by Nassign on Stack Overflow See other posts from Stack Overflow or by Nassign
Published on 2010-06-10T10:59:12Z Indexed on 2010/06/10 11:02 UTC
Read the original article Hit count: 186

Filed under:
|
|
|

I am currently trying to convert a VB6 program into C#. There was extensive use of string splitting into structure. For example,

Dim Sample AS String
Sample = "John Doe        New York  Test Comment"

Public Type Struct1
    Name As String * 15
    Address As String * 10
    Comment As String * 20
End Type

Dim dataStruct As Struct1

Set dataStruct = Sample

When the dataStruct is set, it will automatically split value into the 3 structure member. Is there a special function to do this in C#. The only way I know how to do this is thru Attributes/Annotation describing the length and start position of string. Any other suggestion?

© Stack Overflow or respective owner

Related posts about c#

Related posts about split