3
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace DiffCalc
{
    public partial class newResult : Form
    {
        public newResult()
        {
            InitializeComponent();
        }

        private void newResult_Load(object sender, EventArgs e)
        {
            string s1 = "Have a very good";
            string s2 = "Have a very good day, Joe";
            IEnumerable<string> diff;
            MatchCollection matches = Regex.Matches(s1, @"\b[\w']*\b");

            IEnumerable<string> first = from m in matches.Cast<Match>()
                                       where !string.IsNullOrEmpty(m.Value)
                                       select TrimSuffix(m.Value);
            MatchCollection matches1 = Regex.Matches(s2, @"\b[\w']*\b");
            IEnumerable<string> second = from m in matches1.Cast<Match>()
                                         where !string.IsNullOrEmpty(m.Value)
                                         select TrimSuffix(m.Value);

            if (second.Count() > first.Count())
            {
                diff = second.Except(first).ToList();
            }
            else
            {
                diff = first.Except(second).ToList();
            }
        }
        static string TrimSuffix(string word)
        {
            int apostropheLocation = word.IndexOf('\'');
            if (apostropheLocation != -1)
            {
                word = word.Substring(0, apostropheLocation);
            }
        }

    }
}

Generating error

The call is ambiguous between the following methods or properties: 'System.Linq.Enumerable.Cast(System.Collections.IEnumerable)' and 'System.Linq.Enumerable.Cast(System.Collections.IEnumerable)'

Throwing this error at matches.Cast() line number 27 and similar instances. any help would be appericiated.

René Vogt
  • 43,056
  • 14
  • 77
  • 99
Hardik Mer
  • 824
  • 4
  • 14
  • 26
  • 2
    Read [Call is ambiguous error using Linq](https://stackoverflow.com/a/15874575/6741868) and [Resolving extension methods/LINQ ambiguity](https://stackoverflow.com/questions/453451/resolving-extension-methods-linq-ambiguity). They mention having references mismatched or similar problems. – Keyur PATEL Sep 22 '17 at 09:27
  • removing System.Core.dll worked! thanks – Hardik Mer Sep 22 '17 at 09:38

0 Answers0