w3resource

C#: Combine two given string of length atleast 1, after removing their first character


Combine Strings After Removing First Char

Write a C# Sharp program to combine two strings of length at least 1, after removing their first character.

Visual Presentation:

C# Sharp: Basic Algorithm Exercises - Combine two given string of length atleast 1, after removing their first character.

Sample Solution:-

C# Sharp Code:

using System; // Import the System namespace which contains fundamental types and base classes

namespace exercises // Define a namespace called 'exercises'
{
    class Program // Define a class named 'Program'
    {
        static void Main(string[] args) // The entry point of the program
        {
            // Output the result of the test function with different strings as arguments
            Console.WriteLine(test("Hello", "Hi"));    // Test with strings "Hello" and "Hi"
            Console.WriteLine(test("JS", "Python"));   // Test with strings "JS" and "Python"
            Console.ReadLine(); // Wait for user input before closing the console window
        }

        // Function definition of test function that takes two strings 's1' and 's2' and returns a string
        public static string test(string s1, string s2)
        {
            // Concatenate substrings of 's1' and 's2' starting from index 1 (excluding the first character)
            return s1.Substring(1) + s2.Substring(1);
        }
    }
}

Sample Output:

elloi
Sython

Flowchart:

C# Sharp: Flowchart: Combine two given string of length atleast 1, after removing their first character.

Go to:


PREV : Format Long+Short+Long Strings.
NEXT : Move First Two Characters to End.

C# Sharp Code Editor:



Improve this sample solution and post your code through Disqus

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.