Item 8: Prefer Query Syntax to Loops(Effective C#)
2011-01-15 10:36
501 查看
C# began as an imperative language. It continues to include all the features that are part of that heritage. It’s natural to reach for the most familiar tools at your disposal. However, those tools might not be the best tools. When you find yourself writing any form of a looping construct, ask yourself if you can write that code as a query. If the query syntax does not work, consider using the method call syntax instead. In almost all cases, you’ll find that you create cleaner code than you would using imperative looping constructs.
相关文章推荐
- Item 3: Prefer the is or as Operators to Casts(Effective C#)
- Effective C# Item 11: Prefer foreach Loops
- Effective C#之Item 35:Prefer Overrides to Event Handlers
- Effective Objective-C 2.0:Item 48: Prefer Block Enumeration to for Loops
- Effective C# Item19: Prefer Defining and Implementing Interfaces to Inheritance
- Item 2: Prefer readonly to const(Effective C#)
- Item 12: Prefer Member Initializers to Assignment Statements(Effective C#)
- Item 22: Prefer Defining and Implementing Interfaces to Inheritance(Effective C#)
- Item 30: Prefer Overrides to Event Handlers(Effective C#)
- Effective C#之Item 41:Prefer DataSets to Custom Structures
- Prefer Compiler Error to Runtime Error - taking advantage of the syntax check flag
- Item 3:Prefer the is or as Operation to class
- org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class XXX解决
- Item 10: Use Optional Parameters to Minimize Method Overloads(Effective C#)
- Effective C# Item 35: Prefer Overrides to Event Handlers
- Effective C# 11:Prefer foreach Loops
- org.hibernate.hql.internal.ast.QuerySyntaxException: FwbzItem is not mapped
- org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class xxx
- Effective Objective-C 2.0: Item 41: Prefer Dispatch Queues to Locks for Synchronization
- An Example of Pre-Query and Post-Query Triggers in Oracle Forms With Using Display_Item to Highlight Dynamically