如何将此代码转换为C# [英] How to convert this code to C#

查看:87
本文介绍了如何将此代码转换为C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将此代码转换为C#(scanf(%d%d%d",&m2,&n2,&p2);)

How to convert this code to C# (scanf("%d%d%d",&m2,&n2,&p2);)

推荐答案

您应该添加,"到您的代码,所以正确的问题是如何将(scanf(%d,%d,%d",& m2,& n2,& p2);)转换为C#?


C#代码:


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:


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];
}


如果您的应用程序是C#控制台应用程序,那么您可以说
Console.ReadLine();//读取您在控制台中编写的内容

如果是Windows Form应用程序,则可能必须使用
StreamReader对象并读取行
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


int m2, n2, p2;

m2 = Console.ReadLine();
n2 = Console.ReadLine();
p2 = Console.ReadLine();


这篇关于如何将此代码转换为C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆