Wednesday, March 9, 2016

Convert Datatable to List

private static List<T> ConvertDataTable<T>(DataTable dt)  
{  
    List<T> data = new List<T>();  
    foreach (DataRow row in dt.Rows)  
    {  
        T item = GetItem<T>(row);  
        data.Add(item);  
    }  
    return data;  
}  
private static T GetItem<T>(DataRow dr)  
{  
    Type temp = typeof(T);  
    T obj = Activator.CreateInstance<T>();  
  
    foreach (DataColumn column in dr.Table.Columns)  
    {  
        foreach (PropertyInfo pro in temp.GetProperties())  
        {  
            if (pro.Name == column.ColumnName)  
                pro.SetValue(obj, dr[column.ColumnName], null);  
            else  
                continue;  
        }  
    }  
    return obj;  

Tuesday, March 8, 2016

Visual Studio Expand/Collapse keyboard shortcuts


Collapse to Definitions: CTRL + M + O

Expand all Outlining: CTRL + M + X

Thursday, March 3, 2016

Not Running in Release Mode in Visual Studio

  • Right click Project
  • Properties
  • Build
  • Advanced
  • Set Debug Info to full or pdb only

Tuesday, March 1, 2016

Difference Between "string" and "String"

what is the difference between both (String and string)? After completing the execution of this program when we mouse over on string is shows class System.String and  when we mouse over on String it also shows Class System.String. Class System.String statement clarifying that string is the alias name of String.

Finally:
String is the alias name of String because both contain the same things 

Difference Between "string" and "String"

what is the difference between both (String and string)? After completing the execution of this program when we mouse over on string is shows class System.String and  when we mouse over on String it also shows Class System.String. Class System.String statement clarifying that string is the alias name of String.

Finally:
String is the alias name of String because both contain the same things