Reputation: 11
I'm getting error at Cast<DataRow>
saying that
System.Data.EnumerableRowCollectionExtensions.Cast<TResult (System.Data.EnumerableRowCollection)' is a 'method`
Which is not valid in the given context.
Thanks for the help. Below is my code
StringBuilder sbTmp = new StringBuilder();
dtMessage.AsEnumerable().Cast<DataRow>.ToList.ForEach(x => sbTmp.AppendLine((x["SegmMessage"]).ToString()));
Upvotes: 0
Views: 247
Reputation: 218798
You forgot the parentheses for invoking the Cast
and ToList
methods:
.....Cast<DataRow>().ToList()....
In C# you need to use parentheses to invoke the method and evaluate to its result. Otherwise the compiler thinks you're trying to refer to the physical method itself in the code, not its result.
Upvotes: 3