0
What is the best way to make a string to void conversion uncomplicated.
I tried to use this code but it appears NullException
private void Mainform_Load(object sender, EventArgs e)
{ var method = "public void MSG(object o){ MessageBox.Show(o); }";
method.GetType().GetMethod("MSG").Invoke("MSG", new object[] { "ZZZ" }); //Exception Aqui
}
But it returns the following:
In Place (VS2012) appears the following:
My case is as follows. I want to develop a game Auncher, but this Auncher should be made based on actions SortedDictionary<int, Acion>
where int is the action id and Action is the action based on a string method that is converted to it.
And in an XML would be all the detailed actions:
<?xml version="1.0" encoding="utf-8" ?>
<!-- DO NOT EDIT THIS FILE OR ALL OF THE FUNCTIONS EVEN BECOME INVALID AND UNSTABLE. IN THE CASE MAY RESULT IN SYSTEM FAILURE, AMONG ALL OTHER ERRORS IN COMMON. -->
<rels>
<rel id="0" exec="play_button" />
<rel id="1" exec="reg_button" />
<rel id="2" exec="home_button" />
<rel id="3" exec="clan_button" />
<rel id="4" exec="shop_button" />
<rel id="5" exec="forum_button" />
</rels>
Where rel is declaring the new action, id is the id in int and exec tells Sorteddictionary who should run the function.
And when he prepares to perform the action:
public async void executar_acao(int id){await Task.Run(lista_de_acoes[id]);
The best way is not to. In general people try to do this for the wrong reasons. If you really need to do this, then you’d better set up a script. Which is a lot easier now with the new .Net Compiler Platform.
– Maniero