Hello everyone I want to edit this source
    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Text; 
    using System.Threading.Tasks; 

    namespace G18_20140215 { 
    class Program { 
    static void Main(string[] args) { 
    Console.WriteLine("Hello G_18"); 
    Test("Hello User"); 
    Test("Hello User1"); 
    Sum(2, 3); 
    Console.ReadKey(); 
    } 

    static void Test(string s) { 
    Console.WriteLine(s); 
    } 

    static void Sum(int x, int y) { 
    Console.WriteLine("x + y = " + (x + y)); 
    } 
    } 
    }

------------------------------------------------------------------------------------------------------------------------------

SO THAT I HAD ANSWER LIKE THIS , CAN ANYONE HELP ? ty!
http://imageshack.com/a/img59/403/95a9.png

-------------------------------------------------------------------------------------------------------------------------------

Recommended Answers

Hi fliponymous, welcome at DaniWeb.
Could you tell a bit more clearly, exactly wath you are trying to achieve?

Jump to Post

All 2 Replies

Hi fliponymous, welcome at DaniWeb.
Could you tell a bit more clearly, exactly wath you are trying to achieve?

Try something like the following:

private static int Sum()
        {
            int subTotal = 0;
            string inputVal = string.Empty;

            //read value until an empty line is encountered
            while(!string.IsNullOrEmpty(inputVal=Console.ReadLine()))
            {
                int result = 0;

                //convert string to int 
                //converted string will be in result
                Int32.TryParse(inputVal, out result);

                //add
                subTotal += result;
            }//while
            return subTotal;
        }
Be a part of the DaniWeb community

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