Hi,
this exception makes no sense to me:
Cannot implicitly convert type 'object' to 'char[]'. An explicit conversion exists (are you missing a cast?)

as you can see charQuery is char array and not an object:

string searchedBand = this.txtsearchBand.Text;
            char[] charQuery = searchedBand.ToCharArray();
            String[] dbQuery = new String[(charQuery.Length)];
            for (int i = 0; i < charQuery.Length; i++)
            {
                char[] option = charQuery.Clone();
                option[i] = '*';
                dbQuery[i] = option.ToString();
            }

any reason what the problem is?

Thanks,
Mot.

Exception accrues in line 6:
char[] option = charQuery.Clone();

The Clone method always returns an object of type object.
A char[] is in fact also an object, but of type char[].
C# is very picky about this.
With reason, you cannot compare apples with pears.
So if you are absolutly sure your pear is in fact an apple, do the following : (use a cast)
char[] option = (char[])charQuery.Clone();

Comments
Excellent analogy!

char[] option = charQuery.Clone();

In a loop u are declaring an array. Please its so wrong.

Declare it outside the for loop and enter the values inside the loop that should solve the problem for itself.

And your logical concept is not clear to me. You want to put the values element by element into this new array right ? So
do this
option=charQuery;
if u want to copy items of charQuery in option.

and remember everything is of object type since every data type derives from System.object class.

Read more books.

You are right lonelyrider.
Your suggestion is what I would use too.
I was just anwsering his/her question, Clone works but it copies charQuery and assigns it to option.
And OP's logic is indeed weird:
-->copy charQuery and assign it to option
-->set char i of option to '*'
-->assign option.ToString to string i of the dbQuery string array, wich would fill the array with "System.Char[]" strings.

There is more.
Because the option variable is defined INSIDE the for loop, it does not exist ouside the loop, but perhaps that is the intention...

This article has been dead for over six months. Start a new discussion instead.