I have to do following kind of conversions where my source string can have one or two periods and where each number is represented by two digits. So a “1” becomes “01” and a “90” becomes “90”. Here’s an example of the before -> after
0.0 -> 0000
1.1 -> 0101
10.10 -> 1010
1.88 -> 0188
1.11.22 -> 011122
33.44.5 -> 334405
I have the following function but it does work for the different combinations. Can anyone suggest how I can make it work for the case where there are 1 or 2 periods in my input:
public string DotFormatToRowKey(string tempRowKey) {
return string.Join("", from s in id.Split('.')
select s.PadLeft(2, '0')).PadRight(4, '0'));
}
This should work:
Reference: http://msdn.microsoft.com/en-us/library/dd260048.aspx