Get duplicate records for multiple columns in datatable using LINQ

In this example i am finding duplicate records from the Datatable by using Linq.

using System.Data;
using System.Linq;
namespace ConsoleApplication1
class Program
static void Main(string[] args)
var duplicates = GetTable().AsEnumerable().GroupBy(i => new
Name = i.Field<string>("Name"),
Subect = i.Field<string>("Subject")
}).Where(g => g.Count() > 1).Select(g => new{ g.Key.Name, g.Key.Subect}).ToList();
static DataTable GetTable()
var table = new DataTable();
table.Columns.Add("Name", typeof(string));
table.Columns.Add("Subject", typeof(string));
table.Rows.Add("Jameel", "Maths");
table.Rows.Add("Jameel", "Maths");
table.Rows.Add("Arun", "Chemistry");
return table;

Enjoy programmming

How C#5 “await” works?

Let’s we have the following method that’s contain await keyword. The way the compiler will rewrite this its take the first half (marked as red), it’s splitting your method in to halfway see’s the await keyword and identifying first half of the code and second half will be the following code (marked it as green).
And then rewrites in to the following
In this first half of the code running synchronously in your method and the second half inside the continue with callback. If you are not in C#5 you can write code like that.

Give permissions to a folder pro grammatically using .net in windows

The below source codes allow you to give permissions to everyone for folder. When we need to upload or save some documents to a folder sometimes restricts the actions because of some permissions . In order to avoid this issue we can change permissions of a folder programmatically

var dInfo = new DirectoryInfo(@"C:\\MyFolder");
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.NoPropagateInherit, AccessControlType.Allow));

Enjoy coding….