C
C#3y ago
Surihia

✅ Getting a string value from a set of strings stored in a text file

I have a text file which has strings written in this following pattern:
Name:Age:DOB:Designation
Name:Age:DOB:Designation
With data its as follows. imaginary names:
Jon:30:99:Editor
Jon:30:99:Editor
These strings are all in each line and I want to get the Name, Age, DOB, and Designation strings as separate strings so that I can use them as variables in my program to parse. How do I go about in doing this ?
7 Replies
Angius
Angius3y ago
Split
MODiX
MODiX3y ago
Angius#1586
REPL Result: Success
"Jon:30:99:Editor".Split(':')
"Jon:30:99:Editor".Split(':')
Result: string[]
[
"Jon",
"30",
"99",
"Editor"
]
[
"Jon",
"30",
"99",
"Editor"
]
Compile: 499.135ms | Execution: 28.075ms | React with ❌ to remove this embed.
TheSnowOwl
TheSnowOwl3y ago
yes.... that... didnt know about the handy dandy bot
Surihia
SurihiaOP3y ago
How do I assign each of them as variables ?
Angius
Angius3y ago
Manually It's an array, so just get the element you need and assign it Might want to parse the numeric values to integers too
Surihia
SurihiaOP3y ago
Got it. thank you so much for the help. its fine. I will manage it with what I have now. All that remains now is to determine how to read each line in a for loop.
Accord
Accord2y ago
Closed!
Want results from more Discord servers?
Add your server