Note: I've chosen to answer this question assuming you are talking about setting the background color of selected text: to set the text foreground color, just substitute 'SelectionColor' in the examples below for 'SelectionBackColor.'
Assuming a WinForms RichTextBox control named 'richTextBox1: you can modify, at run-time, the background color of any currently selected text like this:
richTextBox1.SelectionBackColor = Color.Gold;
RichTextBox 'SelectionBackColor' is a Property with both 'set and 'get methods: so you can analyze what color the current background color is, and do various things based on the result of your analysis, if you wish.
And, of course you can manipulate the background color of the RTF text programmatically by setting your own selection:
richTextBox1.Text = @"line1
line2
line3
line4";
richTextBox1.SelectionStart = 0;
richTextBox1.SelectionLength = 5;
richTextBox1.SelectionBackColor = Color.LightSkyBlue;
What happens if your selected text in the RichTextBox contains more than one color ? May I suggest you explore, in that case, what the value returned by 'SelectionBackColor' will be.