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.
Well you could use delegates, but I really wouldn’t. I’d just use:
That’s a lot clearer in terms of what it’s doing, IMO.
Here’s the delegate version in all its hideousness: