How to set substring in ASP.Net C#
In this article, we will learn about how to set a
sub string in asp.net c#, much time we need to require a part of whole string
.
Syntax:-
string.Substring (int startIndex, int length)
Int
startIndex:- int startIndex indicates where
substring start at a specified character position and has a specified length .
StartIndex always works on zero based
starting character position of substring .
Int
length:- Int length indicates as the number of characters in
substing.
Example:-
Code behind (c#)
using System;
using
System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebControls;
public partial class labelvalue : System.Web.UI.Page
{
protected void Page_Load(object
sender, EventArgs e)
{
string
str = "Code Solutions provide the code
solution of ASP.Net with C#, SQL SERVER";
string strvalue = str.Substring(0, 14);
TextBox1.Text = strvalue;
}
}
Out-Put:-
How to set substring in ASP.Net C#
Reviewed by NEERAJ SRIVASTAVA
on
4:23:00 PM
Rating:
Thanks for sharing the syntax of substring keep it up
ReplyDeleteasp.net training in jaipur