Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

How to take input from USER'S in C#:-

To take input from User's in C# We will using Console.ReadLine()  It will return data in String pattern which can be easily typecast into different datatype.

User's Input based on Different Datatype:-

1)    int a =  int.Parse(Console.ReadLine())

2)    float b = float.Parse(Console.ReadLine())

3)    String s =   Console.ReadLine()

4)    char ch = char.Parse(Console.ReadLine())

Complete Program Explanation to take input from users.

using System;   //namespace which contains predefined classes
class SI

  public static void Main()
      float p,r,t,si;
      Console.WriteLine("Enter value for P");
      Console.WriteLine("Enter value for R");
      Console.WriteLine("Enter value for T");
      si= (p*r*t)/100;
      Console.WriteLine("result is " + si);


//  float.Parse() is the predefine method which is used to convert float String to float value.


Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post