Posts

Showing posts from 2017

Difference between == & === in JavaScript

== Check value only. === Check value and its type also. <! DOCTYPE html > < html lang ="en" xmlns ="http://www.w3.org/1999/xhtml"> < head >     < meta charset ="utf-8" />     < title > Difference between == & === in JavaScript </ title > </ head > < body >     < script type ="text/javascript">         var b = true ;         if (b == 1) // return true         {             document.writeln( "Check value only" );         }         if (b === 1) // return false as variable "b" is boolean type and "1" is number         {          ...

Convert List to list of enum (List) in C#

Image
Convert List<string> to list of enum (List<enumType>) in C# using System; using System.Collections.Generic; using System.ComponentModel; using System.Reflection; using System.Linq; namespace TestApp {     public enum Days     {         [ Description ( "Monday" )]         MON,         [ Description ( "Tuesday" )]         TUE,         [ Description ( "Wednesday" )]         WED,         [ Description ( "Thursday" )]         THU,         [ Description ( "Friday" )]         FRI,         [ Description ( "Saturday" )] ...

Get Enum Description value in C#

Enum : According to Microsoft Docs ( Link ), the enum keyword is used to declare an enumeration, a distinct type that consists of a set of named constants called the enumerator list. Enum Description Value: This can be achieve by creating an extension method over the Enum data type. using System; using System.ComponentModel; using System.Reflection; namespace TestApp {     public enum Days     {         [ Description ( "Monday" )]         MON,         [ Description ( "Tuesday" )]         TUE,         [ Description ( "Wednesday" )]         WED,         [ Description ( "Thursday" )]         THU,      ...

Convert string into Title Case in C# by Extension method Without using TextInfo class

Image
public static class StringExtension     {         /// <summary>         /// Use to convert string in Title Case         /// </summary>         /// <param name="str"></param>         /// <returns></returns>         public static string ToTitleCase( this string str)         {             if (! String .IsNullOrEmpty(str))                 return String .Join( " " , str.Split( ' ' ).Select(i => i.Length > 0 ? (i.Substring(0, 1).ToUpper() + i.Substring(1).ToLower()) : i).ToArray());        ...

Convert string into Title Case in C#

Convert string into Title Case in C#  by Extension method 1.       using TextInfo class.  public static class StringExtension     {         /// <summary>         /// Use to convert string into Title Case         /// </summary>         /// <param name="str"></param>         /// <returns></returns>         public static string ToTitleCase( this string str)         {             if (! String .IsNullOrEmpty(str))                 return System.Threading. Thread .CurrentThread.CurrentCulture.TextI...