Displaying the sum of two numbers input from the keyboard. : Console « Development Class « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » Development Class » ConsoleScreenshots 
Displaying the sum of two numbers input from the keyboard.
  

using System;

public class Addition
{
   public static void Mainstring[] args )
   {
      int number1; 
      int number2; 
      int sum; 

      Console.Write"Enter first integer: " )
      number1 = Convert.ToInt32Console.ReadLine() );

      Console.Write"Enter second integer: " );
      number2 = Convert.ToInt32Console.ReadLine() );

      sum = number1 + number2;

      Console.WriteLine"Sum is {0}", sum );
   
}


           
         
    
  
Related examples in the same category
1.Echo some stats
2.Read a line of string and check its length
3.WriteLine and Write
4.Printing one line of text with multiple statements.
5.Printing multiple lines with a single statement.
6.Printing multiple lines of text with string formatting.
7.Change console foreground color and background colorChange console foreground color and background color
8.Clear consoleClear console
9.Set console: title, window size, buffer height and width, cursor positionSet console: title, window size, buffer height and width, cursor position
10.CursorVisible ResetColor SetWindowSize BufferHeight BufferWidth CursorLeft CursorSize CursorTop
11.Use Red and Green from ConsoleColor
12.Beep
13.Beep(200, 300)
14.Use format specifiers with Console.WriteLine
15.Console Output Util
16.If the console moves, Pause.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.