Non-Invocable member ‘Function’ cannot be used like a method

Hello Team,

I am getting below error while fetching the unique value from excel column.(in C# language)

Can someone assist me to resolve this error or do we have another to do the same?

Thanks,
Riya

Hi @Riya1

You have given linq expression is in vb which is absolutely correct.

You can try the below for C#

DT.AsEnumerable().Where(row => !string.IsNullOrEmpty(row["ColumnA"].ToString())).Select(row => row["ColumnA"].ToString()).Distinct().ToList()

Hope it helps!!

Hi @Riya1

Use below query

Uniquevalues = DT.AsEnumerable().Select(row => row["YourColumnName"].ToString()).Distinct().ToList();

Regards,

Hi @Riya1 ,
In C#, the syntax for the LINQ query is slightly different from VB.NET.

Try this below LINQ

dt_Input.AsEnumerable().Select(row => row[“First Name”].ToString()).Distinct().ToList();
Thanks,
Muthuraj