In this case, if I understand you correctly, you have multiple delimiters in your string (i.e., ":", "-"). You can use the String.Split method to create an array of parts that you can then traverse (http://msdn.microsoft.com/en-us/library/ms228388%28v=vs.100%29.aspx). In your case:
char[] delimiterChars = { ':', '-'};
string text = @"Casual Leave:12-Medical Leave :13-Annual Leave :03";
string[] words = text.Split(delimiterChars);
resulting in:
//words[0] = "Casual Leave"
//words[1] = "12"
//words[2] = "Medical Leave"
//words[3] = "13"
//words[4] = "Annual Leave"
//words[5] = "03"
If you would like finer-grained control, you could use String.Substring as so:
using System;
using System.Collections.Generic;
using System.Text;
namespace StackOverflowDemoCode
{
class Program
{
static void Main()
{
// Dictionary string
const string s = @"Casual Leave:12-Medical Leave :13-Annual Leave :03";
const int lengthOfValue = 2;
// Convert to make sure we find the key regardless of case
string sUpper = s.ToUpper();
string key = @"Casual Leave:".ToUpper();
// Location of the value
// Start of the key plus its length will put us at the end
int i = sUpper.IndexOf(key) + key.Length;
// pull value from original string, not UPPERCASE string
string d = s.Substring(i, lengthOfValue);
Console.WriteLine(d);
Console.ReadLine();
}
}
}
Hope this helps you get what you're after!
-
and then the individual ones on: