Extract substring from starting to specified length in C#

Extract string using substring from starting to specified length in C# Programming:


Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MyFirstConsoleApp.Methods
{
    public class subStrExtractions
    {
        public void subStringLength()
        {
            string input = "abcdefinition";
            string result = input.Substring(0,3);
            Console.WriteLine($"input is {input}. Extract substring from starting to specified length " + result);
        }
    }
}

 

Output:

input is abcdefinition. Extract substring from starting to specified length abc





Comments

Post a Comment

Popular posts from this blog

Factory Method Design Pattern in .NET — Real-Time Finance Example

Logging in .NET Core: Built-in Logging vs Serilog with Full Implementation Guide

Implementing Single Sign-On (SSO) in .NET Core and Angular