I have the following string which i would like to retrieve some values from:
============================
Control 127232:
map #;-
============================
Control 127235:
map $;NULL
============================
Control 127236:
I want to take only the Control . Hence is there a way to retrieve from that string above into an array containing like [127232, 127235, 127236]?
try this (assuming your string is named s and each line is made with \n):
ret.Add(...)part is not elegant, but works…EDITED:
If you want an array use
string[] arr = ret.ToArray();SYNOPSYS:
I see you’re really a newbie, so I try to explain:
s.Split('\n')creates a string[] (every line in your string).Where(...)part extracts from the array only strings starting with Controlforeachpart navigates through returned array taking one string at a timet.Replace(..)cuts unwanted string outret.Add(...)finally adds searched items into returning list