Useful lamda exp

Customer foundCustomer = null;
foundCustomer = custList.FirstOrDefault(c =>
c.CustomerId == 4);

The lambda expression syntax in C# looks like this:

c => c.CustomerId == 4

The code begins with the set of parameters to the lambda expression. The => is the “goes to” or lambda operator. The remainder of the code is the expression itself. In this case, checking for the item in the list where CustomerId is 4.


Customer foundCustomer = null;
var query = from c in custList
where c.CustomerId == 4
select c;
foundCustomer = query.FirstOrDefault();


Customer foundCustomer = null;
foreach (var c in custList)
if (c.CustomerId == 4)
foundCustomer = c;

Read Users' Comments (0)

Useful regular expressions

Regex syntax is :

Regex re = new Regex("Regular Expression string",Regular Expression Options);

Regular Expression Options are options that we can use along with regular expression like RegexOptions.IgnoreCase or RegexOptions.Compiled

Here I am lisitng some Regular Expressions:

[a-zA-Z]* - Regular Expression to allow only charactors

[0-9]* - Regular Expression to allow only numbers

[a-zA-Z0-9]* - Regular Expression to allow only alphanumeric charactors

[0-9]*(\.[0-9]{1,2})? - Regular Expression to validate a float number with 1 or 2 decimal points

Read Users' Comments (0)

XAML Overview (WPF)

XAML itself is a larger language concept than WPF.

XAML is a declarative markup language. As applied to the .NET Framework programming model, XAML simplifies creating a UI for a .NET Framework application.
You can create visible UI elements in the declarative XAML markup, and then separate the UI definition from the run-time logic by using code-behind files, joined to the markup through partial class definitions. XAML directly represents the instantiation of objects in a specific set of backing types defined in assemblies. This is unlike most other markup languages, which are typically an interpreted language without such a direct tie to a backing type system. XAML enables a workflow where separate parties can work on the UI and the logic of an application, using potentially different tools.

When represented as text, XAML files are XML files that generally have the .xaml extension. The files can be encoded by any XML encoding, but encoding as UTF-8 is typical.

The following example shows how you might create a button as part of a UI. This example is just intended to give you a flavor of how XAML represents common UI programming metaphors.

Read Users' Comments (0)

Design Patterns in .net

Creational Patterns
Abstract Factory Creates an instance of several families of classes
Builder Separates object construction from its representation
Factory Method Creates an instance of several derived classes
Prototype A fully initialized instance to be copied or cloned
Singleton A class of which only a single instance can exist

Structural Patterns
Adapter Match interfaces of different classes
Bridge Separates an object’s interface from its implementation
Composite A tree structure of simple and composite objects
Decorator Add responsibilities to objects dynamically
Facade A single class that represents an entire subsystem
Flyweight A fine-grained instance used for efficient sharing
Proxy An object representing another object

Behavioral Patterns
Chain of Resp. A way of passing a request between a chain of objects
Command Encapsulate a command request as an object
Interpreter A way to include language elements in a program
Iterator Sequentially access the elements of a collection
Mediator Defines simplified communication between classes
Memento Capture and restore an object's internal state
Observer A way of notifying change to a number of classes
State Alter an object's behavior when its state changes
Strategy Encapsulates an algorithm inside a class
Template Method Defer the exact steps of an algorithm to a subclass
Visitor Defines a new operation to a class without change

Read Users' Comments (0)

Read Users' Comments (0)


Read Users' Comments (0)