Skip to main content

ASP.Net C# Substring String Function

In ASP.Net C# substring string function returns the part of a string starting from the specified starting index of character position to the specified length of the provided string. C# substring function has 2 overloads as follows:
1. Substring(int startIndex)
2. Substring(int startIndex, int length)
1st type of Substring overloaded function accepts only single parameter as integer type starting index of the character position in the specified string. 2nd type Substring overloaded function accepts two types of parameters, first as integer type starting index of the character position in the string and second parameter as the integer type length or the number of characters to be returned as the substring of specified string.
String Functions Examples:
You can see the live samples and examples of String functions from the following links:

Example of ASP.Net C# Substring String Function

Example 1
  1. string strText = "C# substring function";  
  2.   
  3. Response.Write(strText.Substring(3));  
Output


substring function
In above example of C# substring functions starting from 0 as the index of first character of the string you will get the substring starting from start index 3 as following:
01234567891011121314151617181920
C# Substring funtion
Example 2
  1. string strText = "C# substring function";  
  2.   
  3. Response.Write(strText.Substring(3, 9));  
Output


substring
In the above example starting from the 0 as the index of first character of string you will get the substring starting from index number 3 with length of 9 characters as following:
01234567891011121314151617181920
C# Substring function
   123456789         
Output:
You can learn more about C# Substring function from the sample below:
String Substring Function

Comments

Popular posts from this blog

.NET Core API With Dapper, Repository And UnitOfWork

  Introduction In this tutorial, you will use ASP.NET Core Web API to create a web API that returns a list of brands. This article focuses on creating web API using dapper, repository pattern, and UnitOfWork pattern in .NET 8. I will guide you through the steps by step to create web API. HTTP is not just for serving up web pages. HTTP is also a powerful platform for building APIs that expose services and data. HTTP is simple, flexible, and ubiquitous. Almost any platform that you can think of has an HTTP library, so HTTP services can reach a broad range of clients, including browsers, mobile devices, and traditional desktop applications. ASP.NET Core Web API is a framework for building web APIs on top of the .NET Framework. Creating a New Project in Visual Studio Launch Visual Studio and select Create a New Project. Creating a Core Web API Start Visual Studio and choose Create a new project. In the Create a new project dialog, select ASP.NET Core Web API Click Next. Configuring You...

.Net framework interview questions

What is the .NET Framework? The .NET Framework is a set of technologies that form an integral part of the .NET Platform. It is Microsoft’s managed code programming model for building applications. The .NET Framework has two main components: Common Language Runtime (CLR): The CLR is one of the foundation in the .NET framework and provides a common set of services for applications developed on Microsoft .Net Technologies. .NET Framework class library: The .NET framework class library is a collection of reusable types and exposes features of the runtime. It contains of a set of classes that is used to access common functionality. What is CTS (Common Type System)? The common type system (CTS) defines how types are declared, used, and managed in the runtime, and is also an important part of the runtime’s support for cross-language integration. The common type system performs the following functions: ·          Establishes a framework that...

Move Selected Gridview Rows to Another Gridview in Asp.net

Introduction :  Here I will explain how to move or transfer selected checkbox gridview rows to another  grid v iew in asp.net using c#, vb.net or copy one gridview row to another gridview in asp.net using c#, vb.net. Description :  In previous posts I explained Display images in gridview from database in asp.net, Enable/Disable checkbox in gridview based on condition,  asp.net gridview examples  and  bind data to textbox control in gridview ,  Bind data to dropdownlist  in gridview  and many articles relating to  asp.net,  c#, vb.net, c#,vb.net. Now I will explain how to move selected rows from one gridview to another gridview in asp.netusing c#, vb.net. To implement this first we need to write the code in aspx page like this  < html   xmlns ="http://www.w3.org/1999/xhtml"> < head > ...