How can I throw an exception in C# if a string does not match a format?
<p>If I do the following assignement when vm.TempRowKey is null then will the value of newRowKey be null?</p>

<pre><code>var newRowKey = vm.TempRowKey.DotFormatToRowKey();
</code></pre>

<p>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?</p>

<pre><code>public static string DotFormatToRowKey(this string dotFormatRowKey) {
    var splits = dotFormatRowKey.Split('.')
                 .Select(x =&gt; String.Format("{0:d2}", Int32.Parse(x)))
                 .ToList();
    return String.Join(String.Empty, splits.ToArray());
}
</code></pre>
