conditions (1,743)


language agnostic - How do you handle huge if-conditions?

language agnostic - How do you handle huge if-conditions?

It's something that's bugged me in every language I've used, I have an if statement but the conditional part has so many checks that I have to split it over multiple lines, use a nested if statement o…


c# - Conditional Linq Queries

We're working on a Log Viewer. The use will have the option to filter by user, severity, etc. In the Sql days I'd add to the query string, but I want to do it with Linq. How can I conditionally add wh…


How can I test STDIN without blocking in Perl?

I'm writing my first Perl app-- an AOL Instant Messenger bot that talks to an Arduino microcontroller, which in turn controls a servo that will push the power button on our sysadmin's server, which…


c# - Creating a LINQ select from multiple tables

This query works great: var pageObject=(from op in db.ObjectPermissions join pg in db.Pages on op.ObjectPermissionName equals page.PageName where pg.PageID== pag…


Shorthand conditional in C# similar to SQL 'in' keyword

In C# is there a shorthand way to write this: public static bool IsAllowed(int userID){return(userID== Personnel.JohnDoe || userID== Personnel.JaneDoe...);}Like: public static bool IsAllo…



c# - What is the syntax for an inner join in LINQ to SQL?

I'm writing a LINQ to SQL statement, and I'm after the standard syntax for a normal inner join with an ON clause in C#. How do you represent the following in LINQ to SQL: select DealerContact.* from D…


Test Cases AND assertion statements

The code in this question made me think assert(value>0);//Precondition if(value>0){//Doit}I never write the if-statement. Asserting is enough/all you can do. "Crash early, crash often" CodeC…


c - Formatting of if Statements

This isn't a holy war, this isn't a question of "which is better". What are the pros of using the following format for single statement if blocks. if(x) print "x is true"; if(x) print "x is tr…


How do I efficiently filter computed values within a Python list comprehension?

The Python list comprehension syntax makes it easy to filter values within a comprehension. For example: result=[x**2 for x in mylist if type(x) is int] Will return a list of the squares of intege…


How do I get Team Build to run MbUnit tests?

I am having trouble getting Team Build to execute my MbUnit unit tests. I have tried to edit TFSBuild.proj and added the following parts:<Project...><UsingTask TaskName="MbUnit.MSBuild.Tasks.MbU…




multiple statement with else example select condition how for not