❔ assign a local string function to a string variable

string parameters = ";mediaType = " + mediaTypeCombo +";" + string res() { if (mediaTypeCombo.Text == "mp3") { return ""; } else return mediaTypeCombo.Text; };
string parameters = ";mediaType = " + mediaTypeCombo +";" + string res() { if (mediaTypeCombo.Text == "mp3") { return ""; } else return mediaTypeCombo.Text; };
Is something like this possible?
5 Replies
Thinker
Thinker2y ago
You probably want mediaTypeCombo.Text == "mp3" ? "" : mediaTypeCombo.Text condition ? valueIfTrue : valueIfFalse You can do another hideous thing which actually involves anonymous functions, but don't.
Angius
Angius2y ago
Or, if you really want a local function,
string parameters = $";mediaType = {mediaTypeCombo};{res()}";

string res() { if (mediaTypeCombo.Text == "mp3") { return ""; } else return mediaTypeCombo.Text; };
string parameters = $";mediaType = {mediaTypeCombo};{res()}";

string res() { if (mediaTypeCombo.Text == "mp3") { return ""; } else return mediaTypeCombo.Text; };
Thinker
Thinker2y ago
that works i guess
Diesel Geezer
Diesel GeezerOP2y ago
that works thanks a lot
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server