Removing a letter from a String?

Maybe I’m doing this all wrong and I need your help.

I need to remove a single (specific) letter from a string. Here’s what I’ve done so far:

Im raycasting into the scene and when I hit a gameobject (cube) it will call a function to turn that cubes light on. It also gets a string variable called giveLetter which is a single letter and adds that letter to another string called whatWord

In essence I click 3 different cubes to spell a word for example “CAT”. If I click the cube “A” again how would I remove “A” from the word “CAT” and be left with “CT” (no A in the word anymore, of whatWord string variable).

Id really appreciate any help.

I just made and check this below code. Work fine for me. What you have to do just change myString variable value and type with keyboard. It will remove matching character and show you the rest of the string as a output in console window.

#pragma strict
var myString:String="Hello world";
function Update () {    
	for (var c : char in Input.inputString) {
		if (myString.ToLower().Contains(c.ToString())){
			var string1=myString.Substring (0,myString.ToLower().IndexOf(c.ToString().ToLower()));
			var string2=myString.Substring(myString.ToLower().IndexOf(c.ToString().ToLower())+1);
			myString=string1+string2;
			print (myString);
		}
    }
}
whichLetter.whatWord = whichLetter.whatWord.Remove (whichLetter.whatWord.IndexOf (giveLetter), 1);

–Eric

That’s it, Perfect!!! THANK YOU ERIC!

I was missing IndexOf(). doh… and would have never figured that one out. Thats just totally awesome, thank you, thank you, Thank You.