-2

i am trying to pass values to an array in another class this is an example of what i am trying to do in detail:

public class CustomString
{

private string[] StringToAppend;


    public string[] StringToAppend1
    {
        get
        {
            return StringToAppend;
        }

        set
        {
            StringToAppend = value;
        }

       }

  public Class Form1:Form

 {

  CustomString strng1 = new CustomString();

  strng1.StringToAppend1 = {"sssf","vfdr";} //Fails to compile Here 

}

simdi ejinkeonye
  • 111
  • 1
  • 1
  • 7

1 Answers1

0
strng1.StringToAppend1 = {"sssf","vfdr";} //Fails to compile Here 

That is the incorrect syntax for initialising a string array

strng1.StringToAppend1 = new[]{"sssf","vfdr"} ;

Above is the correct syntax.

Jamiec
  • 133,658
  • 13
  • 134
  • 193