我目前通过此方法设置一些字符串:C#访问一个方法值动态地使用字符串
string marketlabel = [email protected]();
我想通过具有用于实际的市场选择一个字符串动态地设置市场标签。
string currentMarketSelected= this.marketTextBox.Text; // Specific market: COLXPM
string [email protected]label.ToString();
我一直在寻找几个小时,可能没有正确解释。我尝试了一些没有成功的思考。基本上我想要做的是有一个文本框或列表,其中包含所有的市场名称和基于哪一个被选择开始设置数据。
以上是我想要做的最好的例子类型,尽管它在语法上不可能在位置上使用变量。
public class Markets
{
public COLXPM COLXPM { get; set; }
//Lots of markets below here
}
public class COLXPM
{
public string marketid { get; set; }
public string label { get; set; }
public string lasttradeprice { get; set; }
public string volume { get; set; }
public string lasttradetime { get; set; }
public string primaryname { get; set; }
public string primarycode { get; set; }
public string secondaryname { get; set; }
public string secondarycode { get; set; }
public List<Recenttrade> recenttrades { get; set; }
public List<Sellorder> sellorders { get; set; }
public List<Buyorder> buyorders { get; set; }
}
public class Return
{
public Markets markets { get; set; }
}
public class RootObject
{
public int success { get; set; }
public Return @return { get; set; }
}
低于所提出的解决方案工作
string currentMarketSelected = "DOGEBTC"; // Just selecting one of the markets to test it works
var property = [email protected]().GetProperty(currentMarketSelected);
dynamic market = property.GetMethod.Invoke([email protected], null);
string marketlabel = market.label.ToString(); //Gets all my selected market data
如果您不知道您正在使用哪些课程,我们无法帮助您。那些看起来完全陌生。 –
删除~~~~~~~~~ – juju
“allmarketdata。@ return.markets”,会不会编译? – Voice