How to use Substring function c#.net

Substring :
"Substring in C# string Class returns a new string that is a substring of this string. The substring begins at the specified given index and extended up to the given length.."

How to Use :

  string  string.Substring(strat index,length)

Input Parameter :
         start index = (Int)
         length = (Int)

Output Parameter :
       string

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 Substring
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string str = null;
            string retString = null;
            str = "This is Nirav M. patel";
            retString = str.Substring(6, 9);
            MessageBox.Show(retString);
        }
    }
}

//////////////////////////////  OUTPUT   /////////////////////////
s Nirav M

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



--
/\/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.