0

Consider the code below,

private void Convert_Click(Object sender, RoutedEventArgs e)
{
          string[] strCmdLineParams = { "str1", "str2", "str3" };

          FormatterUI format = new FormatterUI();
          format.CmdLineParams = strCmdLineParams;
          format.ExecuteRequest();
}

public class FormatterUI
{
          string[] args;

          public string CmdLineParams
          {
              set
              {
                  args=value;
              }
          }

          public void ExecuteRequest()
          {
              //something
          }
}

I want to pass the strings present in strCmdLineParams to ExecuteRequest method as property. But the above code is an error. How can I do this? Please help.

1
  • I think, solution is exactly described in error, which you get Commented Mar 27, 2012 at 11:38

5 Answers 5

4

Define property as string array:

public class FormatterUI
{
      string[] args;

      public string[] CmdLineParams // HERE!!!!
      {
          set
          {
              args=value;
          }
      }
Sign up to request clarification or add additional context in comments.

Comments

2

The type of the property is wrong:

public string[] CmdLineParams 
{ 
  set 
  { 
    args=value; 
  } 
} 

Comments

2

Property CmdLineParams should be a string[] not a string

Comments

1
public class FormatterUI 
{       
    string[] args;        
    public string[] CmdLineParams
    {           
        set           
        {               
            args=value;           
        }       
    } 
}

Declare property with a string[]

Comments

1

Or smiply ...

public class FormatterUI 
{       
    public string[] CmdLineParams
    {  
        set;   
        private get;
    } 

    public void ExecuteRequest()
    {
       //something
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.