"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
///////////////////////////////////////////////////////////////////////////
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@\/ <(.'.)>
0 comments:
Post a Comment
Thanks for comment