The task is such, there is a class containing an array of strings. How to make it so that when describing an object of a class, it was possible to pass any number of lines to the constructor. (In the constructor, strings are accepted using params)

Class A { string[] str; public A(params string[] str1) { for (int i = 0; i < Str.Length;i++ ) Str[i] = str1[i]; } } 

Swears at such a record, saying that an array of null, how to make it rubber?

  • The announcements do not show what Str is (no advertisement), it is not equal to str, this makes the question useless even if there is an answer. - nick_n_a

1 answer 1

Everything, cancellation, it will be correct to write in the constructor simply

Str = str1 without any cycles