Welcome to my blog.

Post on this blog are my experience which I like to share. This blog is completely about sharing my experience and solving others query. So my humble request would be share you queries to me, who knows... maybe I can come up with a solution...
It is good know :-)

Use my contact details below to get directly in touch with me.
Gmail: nadarmuthukumar1987@gmail.com
Yahoo: nadarmuthukumar@yahoo.co.in

Apart from above people can share their queries on programming related stuff also. As me myself a programmer ;-)

Convert List to DataTable in C#

public DataTable ConvertToDataTable<T>(IList<T> data)
    {
        PropertyDescriptorCollection properties =
           TypeDescriptor.GetProperties(typeof(T));
        DataTable table = new DataTable();
        foreach (PropertyDescriptor prop in properties)
            table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
        foreach (T item in data)
        {
            DataRow row = table.NewRow();
            foreach (PropertyDescriptor prop in properties)
                row[prop.Name] = prop.GetValue(item) ?? DBNull.Value;
            table.Rows.Add(row);
        }
        return table;

    }
Reference: Muthukumar (http://nadarmuthukumar.blogspot.in) 
Hope you liked this post, also let me know your thoughts on the post through your valuable comment. 
Thank you.

Find median of an array in c#

public static int GetMedian(int[] Value)
    {
        decimal Median = 0;
        int size = Value.Length;
        int mid = size / 2;
        Median = (size % 2 != 0) ? (decimal)Value[mid] : ((decimal)Value[mid] + (decimal)Value[mid + 1]) / 2;
        return Convert.ToInt32(Math.Round(Median));
    }

Reference: Muthukumar (http://nadarmuthukumar.blogspot.in) 
Hope you liked this and let me know your thoughts on post through your valuable comment.

Thank you

Twitter Delicious Facebook Digg Stumbleupon Favorites More