#help with my assignment cant get it to work

3 messages · Page 1 of 1 (latest)

upbeat hornet
#

Create a class with overloaded methods that accept different parameter types in different orders:
a. Create a class named "StringManipulator". b. Define three methods with the same name "ConcatenateStrings" but with different parameter types and orders. One method should take two strings as parameters and concatenate them in the order they are passed, one should take two strings as parameters and concatenate them in reverse order, and one should take three strings as parameters and concatenate them in a specific order (for example, concatenate the second string, then the first string, then the third string). c. Implement each method to concatenate the input strings in the specified order and return the result. d. In the main method, create an instance of the StringManipulator class and call each method with different arguments. e. Print the result returned by each method.

#
using System;
namespace Lab05
{
    public class StringManipulator
    {
        public string ConcatenateStrings( string str1, string str2)
        {
            return str1 + str2;
        }
        public string ConcatenateStrings(string str2, string str1)
        {
            return str2 + str1;
        }
        public string ConcatenateStrings(string str2, string str1, string str3)
        {
            return str2 + str1 + str3;
        }

    }
}
using System;
namespace Lab05
{
    public class Program
    {
        public static void Main(string[] args)
        {
            StringManipulator obj = new StringManipulator();

            string result1 = obj.ConcatenateStrings("Hello, ", "World!");
            Console.WriteLine("Result 1: " + result1);

            string result2 = obj.ConcatenateStrings("Hello, ", "World!");
            Console.WriteLine("Result 2: " + result2);

            string result3 = obj.ConcatenateStrings("Hello, ", "World!", " Welcome!");
            Console.WriteLine("Result 3: " + result3);

            Console.ReadKey();
        }
    }

}```
#

giving me error CS0116