0

I am trying to catch and exception message as below and running into below errors,can anyone provided inputs on how to fix this?is there a better way to handle string matching?

            catch (Exception ex)
            {
                ////catch
                {
                    if (ex.Message.Contains("Reading from the stream has failed", StringComparison.OrdinalIgnoreCase))
                    {
                        throw;
                    }

                    else
                    {
                        throw;
                    }

                }
      }

Error 1 Instance argument: cannot convert from 'string' to 'System.Linq.IQueryable'

Error 2 'string' does not contain a definition for 'Contains' and the best extension method overload 'System.Linq.Queryable.Contains(System.Linq.IQueryable, TSource, System.Collections.Generic.IEqualityComparer)' has some invalid arguments

Error 3 Argument 3: cannot convert from 'System.StringComparison' to 'System.Collections.Generic.IEqualityComparer' C:\Users\gnakkala\gnakkala_dashboard\source\qcom\qca\wconnect\wbit\automation\Dashboard\sandbox\Dashboard.Data.Repository\BuildRepositories\LookaheadGerritsRepository.cs

Sam Axe
  • 33,313
  • 9
  • 55
  • 89
Jeff Short
  • 285
  • 1
  • 5
  • 14

1 Answers1

1

There is no string.Contains() method that takes a StringComparison. Most people end up using an IndexOf() call for this purpose.

StriplingWarrior
  • 151,543
  • 27
  • 246
  • 315