【发布时间】:2019-04-21 01:33:54
【问题描述】:
我刚刚开始学习 C# 并尝试做一些练习。
我想调用这个文件 就像我在 Main 方法中对其他文件所做的那样 但是因为它包含的方法很少
namespace ConsoleApplication1
{
class StringCopies
{
static void Main(string[] args)
{
Console.WriteLine(test("C Sharp"));
Console.WriteLine(test("JS"));
Console.WriteLine(test("a"));
Console.ReadLine();
}
public static string test(string str)
{
return str.Length < 2 ? str : str.Substring(0, 2) + str.Substring(0, 2) + str.Substring(0, 2) + str.Substring(0, 2);
}
}
}
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// new _strings_ZZaremaZ().Run();
//new IfIntPositiveAndNegativeTrue().Run();
//new computeIntIfEqualTriple().Run();
//new ifParameterOrSumEquals20().Run();
//new toLower().Run();
//new longestWord().Run();
//new SplitReverse().Run();
//new FileSize().Run();
//new MultiplyArrays().Run();
//?????new StringLastItem().Run();
//new StringContains().Run();
//new MathMaxMinxyz().Run();
//new toLower3firstToUpperifLess4().Run();
//new ArraySum().Run();
//new oneOfThemIs30orSum30().Run();
//StringCopies myProgram = new StringCopies();
Console.ReadKey();
}
}
}
【问题讨论】:
-
请不要将您的代码包含为图像,而是包含文本(格式为代码示例)
-
ConsoleApplication1.StringCopies.Main(null)? -
我想从“类程序”中调用“类 StringCopies”。如果可能的话
-
我之前在其他课程上做过,但是它们是无效的,所以很容易
-
请澄清您的具体问题或添加其他详细信息以准确突出您的需要。正如目前所写的那样,很难准确地说出你在问什么。请抽出时间拨打tour 并访问help center。您可能还想阅读How to Ask。