Reputation: 2466
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.
Upvotes: 0
Views: 209
Reputation: 3439
Or smiply ...
public class FormatterUI
{
public string[] CmdLineParams
{
set;
private get;
}
public void ExecuteRequest()
{
//something
}
}
Upvotes: 1
Reputation: 12864
public class FormatterUI
{
string[] args;
public string[] CmdLineParams
{
set
{
args=value;
}
}
}
Declare property with a string[]
Upvotes: 1
Reputation: 42333
The type of the property is wrong:
public string[] CmdLineParams
{
set
{
args=value;
}
}
Upvotes: 2
Reputation: 81660
Define property as string array:
public class FormatterUI
{
string[] args;
public string[] CmdLineParams // HERE!!!!
{
set
{
args=value;
}
}
Upvotes: 4