Here is a simplistic approach
static void Main(string[] args)
{
string str = "{ Text = Banana, Value = 81,Text = Apple, Value = 11,Text = Orange, Value = 21 }";
var kvps = str.Trim('{', '}').Replace(" ", "").Replace("Text=", "").Replace(",Value=", ":").Split(',');
foreach (var kvp in kvps)
{
var values = kvp.Split(":");
Console.WriteLine($"Text= {values[0]} Value={values[1]}");
}
Console.ReadLine();
}
Edit
In view of the comment that this method is very inefficient, it may be helpful to show the BenchmarkDotNet
test results for processing a test string formatted as in the example. The test method extracted 1000 key value pairs from a single string in a mean time of 0.2056 milliseconds with an allocated memory use of 210.55KB
BenchmarkDotNet=v0.12.1, OS=Windows 10.0.22621
Intel Core i7-8565U CPU 1.80GHz (Whiskey Lake), 1 CPU, 8 logical and 4 physical cores
| Method | Mean | Error | StdDev | Ratio | Rank | Gen 0 | Gen 1 | Gen 2 | Allocated |
|------- |---------:|--------:|--------:|------:|-----:|--------:|-------:|------:|----------:|
| DoWork | 205.6 us | 4.01 us | 7.12 us | 1.00 | 1 | 51.2695 | 0.2441 | - | 210.55 KB |