I have a weird question about C#.
I have a static class to store methods as extensions. Then, I have the following extension:
public static bool fwHasData(this DataTable table)
{
return (table == null || table.Rows.Count == 0) ? true : false;
}
My question is: exists some way to avoid use the parentheses when I try to use the extension in my code?
Usage:
bool vHasData = MyDataTable.fwHasData(); // Works fine!
Expected usage:
bool vHasData = MyDataTable.fwHasData; // Removing the parentheses
Thanks a lot!
This is not possible in C#. It would require some form of "extension property" syntax, which is not available in C#. It has been suggested in the past, but doesn't exist in the C# language today, nor in the upcoming C# 6 suggestions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With