Avatar of marcia1
marcia1
Flag for Malta asked on

an ssigned variable to char[] but it getting errors why?

i have assigned a variable but it is keeping telling me that is an assigned variable why. the error is Error Use of unassigned local variable 'myWord'
protected void bttest_Click(object sender, EventArgs e)
    {
        string vSql = " select naME, suRName FRom mytable ";
        int    vSqlLgth = 0;
        string vSqlTrim = string.Empty;
        int vCounter = 0;
        int vCounterArray = 0;
        char myLetter;
 
        char[] myWord;
        SqlParser myParser = new SqlParser();
 
        // get length of sql
        vSqlLgth = myParser.getLength(vSql);
        vSqlTrim = myParser.getTrimSql(vSql);
        // just in case of before and after spaces
        vSqlLgth = myParser.getLength(myParser.getTrimSql(vSql));
 
        while (vCounter < vSqlLgth) {
            if (vSqlTrim[vCounter] != ' ') {
 
                myLetter = vSqlTrim[vCounter];
 
                myWord[0] = myLetter;
                Response.Write(myWord);
            }
 
            vCounter++;
            vCounterArray++;
 
        }

Open in new window

C#

Avatar of undefined
Last Comment
p_davis

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Göran Andersson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
p_davis

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes