Main Site Documentation

TinyCLR 0.10 - no String.Contains()?


#1

Any chance we could get String.Contains() implementation added?

image


#2

I think “Contains” just calls IndexOf internally so you could add it yourself via an extension method if you wanted.

    public static class StringExtensions
    {
        public static bool Contains(this string s, string value)
        {
            return s.IndexOf(value) >= 0; // No null reference checking or comparrison method
        }
    }

#3

Thanks, I was using IndexOf() >= 0 directly in all the various locations… that is cleaner at least :slight_smile: