Weather live

+27
°
C
H: +28°
L: +22°
Kathmandu
Friday, 14 August
See 7-Day Forecast
Sat Sun Mon Tue Wed Thu
+24° +26° +27° +26° +25° +26°
+21° +20° +20° +20° +20° +20°

Breaking News

Write a C# program to print hello world and your name in a separate line. (Beginners program of C#)






Write a C# program to print hello world and your name in a separate line.
: Sample solution:

Public class helloWorld

{

      public static void Main()

      {

                  System.Console.WriteLine("Hello World");

                  System.Console.WriteLine("Ajaya Bista");

      }

}

 Sample Output

Hello World

Ajaya Bista

 

System.Console.WriteLine method writes the specified data, followed by the current  line terminator, to the standard output stream.

 

Details of Write Lines() Method:

 

Methods

Description

WriteLine()

This method writes the current line terminator to the standard output stream.

WriteLine(Boolean)

This method writes the text representation of the specified Boolean value, followed by the current line terminator, to the standard output stream.

WriteLine(Char)

This method writes the specified Unicode character, followed by the current line terminator, value to the standard output stream.

WriteLine(Char[])

This method writes the specified array of Unicode characters, followed by the current line terminator, to the standard output stream.

Int32) Int32, WriteLine(Char[],

This method writes the specified subarray of Unicode characters, followed by the current line terminator, to the standard output stream.

WriteLine(Decimal)

This method writes the text representation of the specified Decimal value, followed by the current line terminator, to the standard output stream.

WriteLine(Double)

This method writes the text representation of the specified double-precision floating-point value, followed by the current line terminator, to the standard output stream.

WriteLine(Int32)

This method writes the text representation of the specified 32-bit signed integer value, followed by the current line terminator, to the standard output stream.

WriteLine(Int64)

This method writes the text representation of the specified 64-bit signed integer value, followed by the current line terminator, to the standard output stream.

WriteLine(Object)

This method writes the text representation of the specified object, followed by the current line terminator, to the standard output stream.

WriteLine(Single)

This method writes the text representation of the specified single-precision floating-point value, followed by the current line terminator, to the standard output stream.

WriteLine(String)

This method writes the specified string value, followed by the current line terminator, to the standard output stream.

WriteLine(String,Object)

This method writes the text representation of the specified object, followed by the current line terminator, to the standard output stream using the specified format information.

WriteLine(String,Object,Object)

This method writes the text representation of the specified objects, followed by the current line terminator, to the standard output stream using the specified format information.

WriteLine(String,Object,Object,Object)

This method writes the text representation of the specified objects, followed by the current line terminator, to the standard output stream using the specified format information.

WriteLine(String,Object,Object,Object,Object)

This method writes the text representation of the specified objects and variable-length parameter list, followed by the current line terminator, to the standard output stream using the specified format information.

WriteLine(String,Object[])

This method writes the text representation of the specified array of objects, followed by the current line terminator, to the standard output stream using the specified format information.

WriteLine(UInt32)

This method writes the text representation of the specified 32-bit unsigned integer value, followed by the current line terminator, to the standard output stream.

WriteLine(UInt64)

This method writes the text representation of the specified 64-bit unsigned integer value, followed by the current line terminator, to the standard output stream.

 For More details Goto Source page: https://www.w3resource.com/csharp-exercises

!TOP smartphone under 40k click here!

4 comments:

  1. write a C# program to enter any two number and display its addition result..
    using System;

    public class Program
    {
    public static void Main()
    {
    int num1 , num2 , num3;
    Console.WriteLine("Enter the number one:");
    num1=Convert.ToInt32(Console.ReadLine());
    Console.WriteLine("Enter the number two:");
    num2=Convert.ToInt32(Console.ReadLine());
    num3=num1 + num2;

    Console.WriteLine("Result is:"+ num3);

    }
    }

    ReplyDelete
  2. Write a c# program to check entered number is equal or not....
    using System;

    public class Program
    {
    public static void Main()
    {
    int num1 , num2;
    Console.WriteLine("Enter the number one:");
    num1=Convert.ToInt32(Console.ReadLine());
    Console.WriteLine("Enter the number two:");
    num2=Convert.ToInt32(Console.ReadLine());
    if(num1== num2)
    {
    Console.Write("Equal");
    }
    else
    {
    Console.Write("Not equal");
    }

    }
    }

    ReplyDelete
  3. using System;
    public class Exercise1
    {
    public static void Main()
    {
    int int1,int2;
    Console.Write("\n\n");
    Console.Write("Check whether two integers are equal or not:\n");
    Console.Write("-------------------------------------------");
    Console.Write("\n\n");
    Console.Write("Input 1st number: ");
    int1= Convert.ToInt32(Console.ReadLine());

    Console.Write("Input 2nd number: ");
    int2= Convert.ToInt32(Console.ReadLine());
    Console.Write("\n\n");

    if (int1 == int2)
    Console.WriteLine(" Both are equal.\n");
    else
    Console.WriteLine(" these number are not equal.\n");
    }
    }

    ReplyDelete
  4. Write a c# program to print average of two numbers....

    using System;
    public class Exercise1
    {
    public static void Main()
    {
    int Int1,int2, avg;
    Console.Write("\n\n");
    Console.Write("Average of Two number:\n");
    Console.Write("-------------------------------------------");
    Console.Write("\n\n");
    Console.Write("Input 1st number: ");
    Int1 = Convert.ToInt32(Console.ReadLine());
    Console.Write("Input 2nd number: ");
    int2 = Convert.ToInt32(Console.ReadLine());
    avg= (Int1 + int2)/ 2;


    Console.WriteLine(" The average of two number is.\n"+avg);
    }
    }

    ReplyDelete