I like this!!!
...
ORDER BY
CASE WHEN column = 'this' THEN 2 ELSE 1 END asc,
othercolumn asc,
another column desc
...
to group items separately and then apply a secondary sorting within each group...
csharpeasy
Useful C# & .NET tips
Friday, February 18, 2011
Thursday, March 20, 2008
OOP Concepts
OOP Concepts:
1. POLYMORPHISM: In object-oriented programming, polymorphism (from the Greek meaning "having multiple forms") is the characteristic of being able to assign a different meaning or usage to something in different contexts - specifically, to allow an entity such as a variable, a function, or an object to have more than one form.
2.ENCAPSULATION: Conceptually, encapsulation means hiding the internal details of a class's operation.Goal of encapsulation: use an object without understanding or depending on its internal details.
3.INHERITANCE: Inheritance is used to establish hierarchical class relationships.In inheritance, one class (the subclass) adopts (inherits) the features of another class (the superclass).
4.ABSTRACTION:In object technology, determining the essential characteristics of an object. Abstraction is one of the basic principles of object-oriented design, which allows for creating user-defined data types, known as objects.
1. POLYMORPHISM: In object-oriented programming, polymorphism (from the Greek meaning "having multiple forms") is the characteristic of being able to assign a different meaning or usage to something in different contexts - specifically, to allow an entity such as a variable, a function, or an object to have more than one form.
2.ENCAPSULATION: Conceptually, encapsulation means hiding the internal details of a class's operation.Goal of encapsulation: use an object without understanding or depending on its internal details.
3.INHERITANCE: Inheritance is used to establish hierarchical class relationships.In inheritance, one class (the subclass) adopts (inherits) the features of another class (the superclass).
4.ABSTRACTION:In object technology, determining the essential characteristics of an object. Abstraction is one of the basic principles of object-oriented design, which allows for creating user-defined data types, known as objects.
Wednesday, March 19, 2008
Dispose(), Destructor/Finalizer
Destructors are called by GC (non-deterministic) ~ClassName() in C# & Finalize() method in VB.NET when GC determines it is time for garbage collection.
Not the best place to put cleanup code.
Ex: open a database connection and put the cleanup code in the Destructor. That DB connection might stay open for the life of the entire application. Not good!
Dispose() method:
A better place to put cleanup code.
Mostly used to cleanup unmanaged resources.
using{} statement automatically calls the Dispose() before exiting.
Recommended to be called only if the object is resource intensive.
References:
http://www.dotnetspider.com/qa/Question1450.aspx
Not the best place to put cleanup code.
Ex: open a database connection and put the cleanup code in the Destructor. That DB connection might stay open for the life of the entire application. Not good!
Dispose() method:
A better place to put cleanup code.
Mostly used to cleanup unmanaged resources.
using{} statement automatically calls the Dispose() before exiting.
Recommended to be called only if the object is resource intensive.
References:
http://www.dotnetspider.com/qa/Question1450.aspx
Access Modifiers (public, private, ...)
By default;
classes: internal by default. (can be internal or public, can NOT be private, protected or protected internal)
interfaces & enumerations: always public, no access modifier needed or allowed.
namespaces: always public
Struct members: private by default. (can be public, private, internal)
public: accessible from instance & derived classes
private: NOT accessible from instance nor derived classes
protected: NOT accessible from instance but accessible from derived classes
internal: accessible from instance & derived classes WITHIN THE SAME ASSEMBLY ONLY.
protected internal: NOT accessible from instance but accessible from derived classes of the same assembly.
So, if a member is marked as protected, then it is accessible from derived classes of the SAME assembly or other assemblies.
classes: internal by default. (can be internal or public, can NOT be private, protected or protected internal)
interfaces & enumerations: always public, no access modifier needed or allowed.
namespaces: always public
Struct members: private by default. (can be public, private, internal)
public: accessible from instance & derived classes
private: NOT accessible from instance nor derived classes
protected: NOT accessible from instance but accessible from derived classes
internal: accessible from instance & derived classes WITHIN THE SAME ASSEMBLY ONLY.
protected internal: NOT accessible from instance but accessible from derived classes of the same assembly.
So, if a member is marked as protected, then it is accessible from derived classes of the SAME assembly or other assemblies.
Subscribe to:
Posts (Atom)