How to use IndexOf function c#.net

Substring :
"The IndexOf method in string Class in C# returns the index of the first occurrence of the specified substring.."

How to Use :

 int number = string.IndexOf(string str)

Input Parameter :
         str = (string)

Output Parameter :
       int number

Example  :: 
/////////////////////////  CODE   /////////////////////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace IndexOf
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string str = null;
            str = "driver driveing a car";
            MessageBox.Show(str.IndexOf("driveing").ToString());
        }
    }
}

//////////////////////////////  OUTPUT   /////////////////////////
7

///////////////////////////////////////////////////////////////////////////


--
/\/ir@\/  <(.'.)>

Comments

Popular posts from this blog

How to make and use web service in Microsoft Dynamics Navision.

How to use Format function in Microsoft Dynamics Navision.

How to create simple report in Microsoft Dynamics Navision.