System.Globalization.CompareInfo.IndexOf C# (CSharp) Method

IndexOf() public method

public IndexOf ( String source, String value, int startIndex, int count, CompareOptions options ) : int
source String
value String
startIndex int
count int
options CompareOptions
return int
        public unsafe virtual int IndexOf(String source, String value, int startIndex, int count, CompareOptions options)
        {
            // Validate inputs
            if (source == null)
                throw new ArgumentNullException("source");
            if (value == null)
                throw new ArgumentNullException("value");

            if (startIndex > source.Length)
            {
                throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
            }

            if (source.Length == 0)
            {
                if (value.Length == 0)
                {
                    return 0;
                }
                return -1;
            }

            if (startIndex < 0)
            {
                throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
            }
            
            if (count < 0 || startIndex > source.Length - count)
                throw new ArgumentOutOfRangeException("count",Environment.GetResourceString("ArgumentOutOfRange_Count"));

            if (options == CompareOptions.OrdinalIgnoreCase)
            {
                return TextInfo.IndexOfStringOrdinalIgnoreCase(source, value, startIndex, count);
            }
     
            // Validate CompareOptions
            // Ordinal can't be selected with other flags
            if ((options & ValidIndexMaskOffFlags) != 0 && (options != CompareOptions.Ordinal))
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag"), "options");


            return IndexOfString(m_pSortingTable, this.m_sortingLCID, source, value, startIndex, count, (int)options);
        }
    

Same methods

CompareInfo::IndexOf ( String source, String value ) : int
CompareInfo::IndexOf ( String source, String value, CompareOptions options ) : int
CompareInfo::IndexOf ( String source, String value, int startIndex ) : int
CompareInfo::IndexOf ( String source, String value, int startIndex, CompareOptions options ) : int
CompareInfo::IndexOf ( String source, String value, int startIndex, int count ) : int
CompareInfo::IndexOf ( String source, char value ) : int
CompareInfo::IndexOf ( String source, char value, CompareOptions options ) : int
CompareInfo::IndexOf ( String source, char value, int startIndex ) : int
CompareInfo::IndexOf ( String source, char value, int startIndex, CompareOptions options ) : int
CompareInfo::IndexOf ( String source, char value, int startIndex, int count ) : int
CompareInfo::IndexOf ( String source, char value, int startIndex, int count, CompareOptions options ) : int

Usage Example

        private void LoXIVUpdateHandler(object sender, PropertyChangedEventArgs e)
        {
            var worker = sender as LoXIV;

            if (worker != null)
            {
                foreach (var log in worker.FFXIVlog)
                {
                    if (String.IsNullOrEmpty(Name) || String.IsNullOrEmpty(Prefix))
                    {
                        continue;
                    }

                    if (log.StartsWith(Name))
                    {
                        string prefix;
                        if (Prefix == "{{ss}}")
                        {
                            prefix = " ";
                        }
                        else
                        {
                            prefix = Prefix;
                        }

                        if (ci.IndexOf(log.Substring(Name.Length + 1), prefix, CompareOptions.IgnoreWidth) == 0)
                        {
                            var lorelei = new Lorelei(
                                "",
                                "",
                                "",
                                "");
                            try
                            {
                                lorelei.PostTweet(log.Substring(Name.Length + prefix.Length + 1));
                            }
                            catch { }
                        }
                    }
                }

                var dispatcher = Application.Current.Dispatcher;

                if (dispatcher.CheckAccess())
                {
                    LogList = worker.FFXIVlog;
                }
                else
                {
                    dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() =>
                    {
                        LogList = worker.FFXIVlog;
                    }));
                }
            }
        }
All Usage Examples Of System.Globalization.CompareInfo::IndexOf