How can I make this function with substr work when rk is null or ""
<p>I have the following function in C#:</p>

<pre><code>    public string getRowKey(string topic, string rk)
    {
        return string.Join("", from s in topic.Split('.')
                               select s.PadLeft(2, '0')).PadRight(4, '0') +
                    rk.Substring(4);
    }
</code></pre>

<p>I have a problem because if rk is null or equal to "" then the function is failing. Can someone explain how I can fix this. I am getting an error about index values. Note that if rk is null or "" then I just don't want that last part with rk.Substring(4) added.</p>
