Progress Monitor for IdealProgrammer.com
Take Swift, Intelligent, Massive, Planned, Loving, Effective (S.I.M.P.L.E.) Action to Transform Self into Ideal
Skip Repetitive Navigational Links
Home
News
Presenters
Register
Contact
Categories
Titles
Converter
Code Samples
C# ASP.NET
C# Console
HTML
JavaScript
SQL Server
VB ASP.NET
VB Console
Please login
C-Sharp Substring Example Syntax - C# String Function - Sample Code
Description:
Illustrates the C# Syntax for Substring.
Example Class Main:
using System; public class clsSubstring { public void Main() { //**************************************************************************************** // Example #1: Substring(startIndex[, length]) // Returns the string that starts at the specified position and has the specified // length. If the length is not specified, all of the characters to the end are returned. //**************************************************************************************** Console.WriteLine("Example #1: Substring(startIndex[, length]) "); string strSubstringExample = "This is a test string"; int intIndexSubstring = 0; // First find position of word test intIndexSubstring = strSubstringExample.IndexOf("test"); // Get everything starting at "test" to end of string Console.WriteLine(strSubstringExample.Substring(intIndexSubstring)); //write blank line to make output easier to read Console.WriteLine(); //Prevent console from closing before you press enter Console.ReadLine(); } }
Example Class Program:
using System; using System.Collections.Generic; using System.Linq; using System.Text; nameSubstring CSharp_Syntax { class Program { static void Main(string[] args) { clsSubstring mySubstring = new clsSubstring(); mySubstring.Main(); } } }
Home
News
Presenters
Register
Contact
Categories
Titles
Converter
Code Samples
C# ASP.NET
C# Console
HTML
JavaScript
SQL Server
VB ASP.NET
VB Console