string nameLabels =trainingTable.Rows[rowsNumber]["FaceName"].ToString();

                         string[] labels = (string[])nameLabels;


                 // data comes from ms acces database 
                 // i want to to put all faces names in a string array but in the second line error comes canntot implicitly convert string to string[]

The error is correct. nameLabels is a string (as denoted by your ToString call earlier to convert the cell value), and string is most certainly not a compatible type with string[].

Without more details on what values the "FaceName" cells contain, I can only speculate, but judging by your description of the requirement, I'd approach it like this:

var labels = new string[trainingTable.Rows.Count];

for (int i = 0; i < trainingTable.Rows.Count; i++)
    labels[i] = trainingTable.Rows[i]["FaceName"].ToString();

Of course, arrays are annoying to work with, and my preference would be a list instead:

var labels = new List<string>();

foreach (DataRow row in trainingTable.Rows)

Or if you favor potentially less performant one-liners:

var labels = trainingTable.AsEnumerable().Select(x => x["FaceName"].ToString()).ToList();

Which can be altered to get an array instead of a list by ending with ToArray rather than ToList.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.