If I do the following assignement when vm.TempRowKey is null then will the value of newRowKey be null?
var newRowKey = vm.TempRowKey.DotFormatToRowKey();
Also is there a way that I can make the following throw an exception if the dotFormatRowKey does not have the format x.x where x is a number?
public static string DotFormatToRowKey(this string dotFormatRowKey) {
var splits = dotFormatRowKey.Split('.')
.Select(x => String.Format("{0:d2}", Int32.Parse(x)))
.ToList();
return String.Join(String.Empty, splits.ToArray());
}
Then
TempRowKey.DotFormatToRowKey();will throw a null-reference exception.Small detail: You are using both
ToList()andToArray()onsplits. That is double work and in .NET 4 you don’t need either.