using System.Text;
namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            Cassandra myObject = new Cassandra();
            string a ="söt";
            myObject.hejsan(a);
            System.Console.WriteLine(a);
            Console.ReadLine();
        } 
    }


class Cassandra
        {
            public string hejsan(string value)
            {
                value +="Cassnadra";
                return value;
            }
        }


}

how come this wont work? all i get is "söt" as output when i should get "sötCassandra"
thanks for answers :)

Recommended Answers

All 3 Replies

using System.Text;
namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            Cassandra myObject = new Cassandra();
            string a ="söt";
            a = myObject.hejsan(a);
            System.Console.WriteLine(a);
            Console.ReadLine();
        } 
    }
class Cassandra
        {
            public string hejsan(string value)
            {
                value +="Cassnadra";
                return value;
            }
        }
}

Line 10, you need to assign a to be the output of the method, as I have done in the above code.

hmm now i just get "An unhandled exception of type 'System.StackOverflowException' occurred in ConsoleApplication3.exe" sigh? :D warning me if i have any infinite loops or something like that :O

thank you! you are the savior!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.