希望输出"c尖锐语言"和两个班一起 [英] Want to have output "c sharp language" together with two classes
问题描述
大家好,
伙计们,我是C#语言编码的新手.任何帮助都会很棒:
Hi everyone,
Guys I am new to C# language coding. Any help would be great:
using System;
class programone
{
public static fun()
{
Console.WriteLine("c sharp");
}
}
class programtwo
{
public static void Main()
{
Console.WriteLine(" language" );
}
}
推荐答案
尝试:
class programtwo
{
public static void Main()
{
programone.fun(); //Add this line.
Console.WriteLine(" language ");
}
}
这将在写入单词"language"之前执行类"programone"中的方法"fun"
可能值得添加第二行:
This will execute the method "fun" from class "programone" before it writes the word "language"
It may be worth adding a second line:
class programtwo
{
public static void Main()
{
programone.fun();
Console.WriteLine(" language ");
Console.ReadLine(); //Add this one as well.
}
}
这将导致执行停止,直到您按ENTER键:这样您才能阅读所写内容!
Manas Bhardwaj建议您可能希望输出为单行而不是两行.
如果是这样,则替换该行:
This will cause the execution to stop until you press the ENTER key: that way you can read what you have written!
Manas Bhardwaj Suggests that you might want the output as a single line, rather than two.
If so, then replace the line:
Console.WriteLine("c sharp");
在有趣"方法中使用:
in the "fun" method with:
Console.Write("c sharp");
它将起作用.
[edit]答案已更新-OriginalGriff [/edit]
And it will work.
[edit]Answer updated - OriginalGriff[/edit]
这篇关于希望输出"c尖锐语言"和两个班一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!