0

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

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

3
Contributors
2
Replies
22
Views
3 Years
Discussion Span
Last Post by cgeier
0

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

0

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;
        }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.