in Education by
I want to assign to a datatable such that. If datatable is null create a new datatable else clear datatable The code I have written datatable= (datatable== null) ? new DataTable() : delegate(){datatable.Clear(); return datatable;}); How this will be possible using delegates or anonymous methods? Using shortest code possible. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Well you could use delegates, but I really wouldn't. I'd just use: if (dataTable == null) { dataTable = new DataTable(); } else { dataTable.Clear(); } That's a lot clearer in terms of what it's doing, IMO. Here's the delegate version in all its hideousness: dataTable = dataTable == null ? new DataTable() : ((Func)(() => { dataTable.Clear(); return dataTable; }))();

Related questions

0 votes
    I have Front Matter files like this: --- title: BMW i320 M3 150HP Petrol 2020 category: sportscar ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 5, 2022 in Education by JackTerrance
0 votes
    I have a list of criteria in a database table that are entered by user. This criteria is in a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I want to calculate a percentage, for each id, of True values from all rows of the id. Here an example ... df.num_true/df.num_col1_id Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    If you had enabled a Conditional Access Policy for External Users using multi-factor authentication, and then also ... users, would they trigger both when accessing content?...
asked Mar 10, 2021 in Technology by JackTerrance
0 votes
    I'm working on an extension (BHO) for Internet Explorer, and having trouble attaching a .NET delegate to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I have developed one application in which i have to detect whether user has tapped home button or whether ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I have developed one application in which i have to detect whether user has tapped home button or whether ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    What is a multicast delegate in C#?...
asked Jul 27, 2021 in Technology by JackTerrance
0 votes
0 votes
    What is a delegate in swift?...
asked Nov 30, 2020 in Technology by JackTerrance
0 votes
    What is Business Delegate pattern?...
asked Nov 7, 2020 in Education by Editorial Staff
+1 vote
    To delegate administrative tasks for specific resource groups in Azure which?...
asked Oct 20, 2020 in Technology by JackTerrance
0 votes
    What is fixed credit assignment? (a) reinforcement signal given to input-output pair don't change with time (b) ... (d) none of the mentioned Please answer the above question....
asked Sep 5, 2022 in Education by JackTerrance
0 votes
    What is probablistic credit assignment? (a) reinforcement signal given to input-output pair don't change with time (b ... d) none of the mentioned Please answer the above question....
asked Sep 5, 2022 in Education by JackTerrance
0 votes
    What is temporal credit assignment? (a) reinforcement signal given to input-output pair don't change with time (b) ... (d) none of the mentioned Please answer the above question....
asked Sep 5, 2022 in Education by JackTerrance
...