Formatting DateTime to show only Date in MVC

In MVC Razor view, you might need to show just Date or Time given a DateTime object. Some naive approaches could be (.cshtml):

@String.Format("dd-MMM-yyyy", Model.TestDate)


@Html.TextBoxFor(x => x.TestDate, "{0:dd-MMM-yyyy}")

However, a better way could be overloading the ToString() function for DateTime object as in following helper extension method:.

Read more

Github Push local project to a remote repo

In this post we will upload a local project to a remote repository. invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Develo per/CommandLineTools/usr/bin/xcrun

  1. Create a new Java project named “test” under directory “F:\Github” or you can have your existing project here. E.g. You will have bin, src folder in “F:\Github\test” directory.
  2. In GitShell, change current directory to “test” and initialize a new Git repository here.
 cd F:\Github\test
 git init
Read more

Describing a Programming Language

Recently I came across a very good guideline in the book - PI Exposed about how to explain a programming language to a technical individual. The book suggests to include answers to following five questions while explaining:

  1. What is it: A programming language / framework / library etc.
  2. Application: Where it is used? Web / Windows / Mobile / System app.
  3. What it does: Validation / Update / Implementation etc.
  4. How: Describe a little bit about implementation details.
  5. Advantage: Why this approach is better than others.

Please feel free to share your way to express a technology.

Read more

IEnumerable vs. ICollection vs. IQueryable vs. IList

Collections are used quite often in applications and C# have different types of collection. Here are the subtle differences between collection types and choose appropriate type based on your needs.

IEnumerable: Provides Enumerator for accessing collection

Read more

In-place and out-of-place list sorting in C#

You may need to sort C# list elements in-place sometimes or copy elements of a list to another list according to some sort order (which is in fact another way to sort list elements). Linq provides an easy way to achieve both purposes. Let’s say you have a Project entity with FirstName property.

Read more

Get a C# property name as a string

Recently I came across a situation where I need to pass the name of a property as a string to a constructor. I realized that there is not any in-built framework property or method to achieve so. It makes sense too because the compiler interprets Property Type instead of Property Name. The Property name is for writing human readable (or understandable) code.

If you use this.PropertyName.ToString() then it will convert the value of PropertyName property to string not the name of the property itself.

Read more

Building an MVC 4 website

I joined Motorola Solutions as a Summer Intern in May and was given an assignment to build a full-fledge website from scratch which will be used by a whole department internally. It was an independent development assignment while working with stakeholders. I was given freedom in technology decision as stakeholders were majorly interested in end-product not the intrinsics.

With Freedom Comes Responsibility

Read more