Browsed by
Category: Good practices

Filtering on DataTables

Filtering on DataTables

When you want to apply a filter to your datatable in your dataset, you can use the method Select on the class DataTable. In our current project we use this method very often, also for databinding. Recently I discover an unexpected behaviour. Let’s assume, that our datatable has 4 datarows and we will apply following filter for databinding:0=1 AND Path = ‘C:\bin’ The first expression (0=1) is added by an other method, which checks if any rows should be visible….

Read More Read More

Programming several conditions in C#

Programming several conditions in C#

When you have to programme a piece of code which have several conditions you could do it in the following way: switch(a.name){    case “smith”:        CallHim();         break;    case “doyle”:        SendAMessageToHim();        break;    default:        throw new WriteNotReachableErrorException();} If you couldn’t use constants as conditions, you will implement the logic in the following way: if(a.name == smithObject.ToString()){    CallHim();}else if(a.name == doyleObject.ToString()){    SendAMessageToHim();}else{    throw new WriteNotReachableErrorException();} But if you think now there is now other possibility to implement the logic, wait! I found recently…

Read More Read More