RSS

Monthly Archives: November 2011

Not Taking Risk Is Biggest Risk

“The biggest risk is not taking any risk… In a world that changing really quickly, the only strategy that is guaranteed to fail is not taking risks.”

– Mark Zuckerberg.

Advertisements
 
Leave a comment

Posted by on November 8, 2011 in General

 

Tags: , ,

Dynamic X Object X Var Keywords in C#

Object

Keyword represents the System.Object type, which is the root type in the C# class hierarchy. This keyword is often used when there’s no way to identify the object type at compile time, which often happens in various interoperability scenarios.

Dynamic

Introduced in C# 4, makes certain scenarios that traditionally relied on the object keyword easier to write and maintain. In fact, the dynamic type uses the System.Object type under the hood, but unlike object it doesn’t require explicit cast operations at compile time, because it identifies the type at run time only.

Var

Since C# 3.0, is used for implicitly typed local variables and for anonymous types. This keyword is often used with LINQ. When a variable is declared by using the var keyword, the variable’s type is inferred from the initialization string at compile time. The type of the variable can’t be changed at run time. If the compiler can’t infer the type, it produces a compilation error.

Excerpt from: Understanding the Dynamic Keyword in C# 4. There are more to read, including sample code, from this link.

Another good read is: What is the difference between “dynamic” and “object” keywords?

 
Leave a comment

Posted by on November 8, 2011 in General

 

Tags: ,

ASP.Net MVC 3 Razor View Quick Reference

  • @ : Identify Razor code segment.
  • @* *@ : Comment.
  • @( ) : Indicate pure server-side code. This is only in single line.
  • Razor supports if else, while, do while, and foreach statement
  • @{ } : Indicate code block. This can be written in multiple lines.
  • Code block is not purely server-side code, it can also contains client-side code (HTML).
  • In code block, HTML elements is required to indicate client-side content.
  • Use <text></text> element in code block to identify client-side text.
  • @model : Keyword to define a model.
  • @section : Keyword to render code / text to pre-defined section.
  • @helper : Keyword to define a helper which create a reusable code snippet.
  • @functions : Keyword to define a function which provides pure server-side methods that can be reused within the view.
  • @RenderBody() : Method to render all the content of the view. A placeholder for view’s entire content.
  • @RenderSection() : Method to define a region that content will be inserted into by consuming view.
 
Leave a comment

Posted by on November 1, 2011 in References

 

Tags: ,

 
%d bloggers like this: