Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
How to convert this code to C# (scanf("%d%d%d",&m2,&n2,&p2);)
Posted
Updated 16-Jul-12 21:30pm
v2
Comments
StianSandberg 17-Jul-12 3:10am    
you should find a c++ --> c# converter...

You should add "," to your code,so the correct question is that How to convert (scanf("%d,%d,%d",&m2,&n2,&p2);) to C#?


C# code:


C#
using system;
int m2,n2,p2;
string input=Console.ReadLine();
string[] substr=input.Split(',');
if (substr.Length>=3)
{
  m2=int.Parse(substr[0]);
  n2=int.Parse(substr[1]);
  p2=int.Parse(substr[2];
}
 
Share this answer
 
If your application is a C# console application then you can say
Console.ReadLine();// reads what ever you wrote in the console

If it is windows Form application then you may have to use
StreamReader object and do readline
 
Share this answer
 
C#
int m2, n2, p2;

m2 = Console.ReadLine();
n2 = Console.ReadLine();
p2 = Console.ReadLine();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900