K
K
K A2019-03-05 12:43:33
Arrays
K A, 2019-03-05 12:43:33

Why does it give the error "Cannot implicitly convert type 'int[]' to 'char[]"?

Аргументом метода символьный массив, метод возвращает ссылку на массив чисел символов.

using System;

class ArgArray
{
    static char[] SymbsArr(char[] n)
    {
        int[] numbs = new int[n.Length];
        for (int i = 0; i < numbs.Length; i++)
        {
            numbs[i] = (int)n[i];
        }
        return numbs;
    }

    static void Main()
    {
        char[] symbs = { 'A', 'B', 'C', 'a', 'b', 'c' };
        int[] numbs;
        numbs = SymbsArr(symbs);
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
K A, 2019-03-05
@russrage

static int [] SymbsArr(char[] n)
found the error myself))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question