Trouble with insert if logic

I'm having a little of trouble getting my head around this - maybe because its late in the day!

For the beginning of this I am doing it simply so here is what I have:

A user has 4 Attributes amended to their profile (or you can think of it as a database):

  • Age
  • Budget
  • Gender
  • Transport

First condition is:

If one of these four attributes is not empty then I show an image. I have done this one like this:

If not empty age Then IMG or If not empty Budget then IMG

And so on.

I just need some guidance on:

  • How to show an IMG if any 2,3 or 4 of the four are not empty

Can't seem to get my head around the logic. I think I can do it but it would end up quite a large expression.

thanks!

Answers


Instead of

if (age not empty) then
    IMG
else if (budget not empty) then
    IMG
...

I suggest you write it as

if (!(age empty && budget empty && gender empty && transport empty)) then
    IMG

Need Your Help

Async tasks and Simple Injector Lifetime scopes

c# multithreading asynchronous inversion-of-control simple-injector

I've got the following method which resolves an IConsumeAsync which returns a task.