using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
if (/* 补充这里 */)
Console.Write("Hello");
else
Console.Write(" World!");
}
}
}
用C#语言,至少我已经想到了三种不同原理的答案。
欢迎大家想出更多的答案。
我会在若干天以后公布我所想到的答案。
------解决方案-------------------- using System; public class HelloWorld { public HelloWorld() { Console.WriteLine("HELLO WORLD"); } public static void Main() { HelloWorld hw = new HelloWorld(); } }
using System; public class HelloWorld { public void helloWorld() { Console.WriteLine("HELLO WORLD"); }
public static void Main() { HelloWorld hw = new HelloWorld(); hw.HelloWorld(); }
using System; interface IHelloWorld { void writeHelloWorld(); } public class HelloWorld : IHelloWorld { public void writeHelloWorld() { Console.WriteLine("Hello World"); } public static void Main() { HelloWorld hw = new HelloWorld(); hw.writeHelloWorld(); } } }
------解决方案--------------------
C# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
if (Convet.ToBool(Console.Write("Hello")))
Console.Write("Hello");
else
Console.Write(" World!");
}
}
}
------解决方案--------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
if (new Func<bool>(() => { Console.Write("Hello"); return false; }).Invoke())
Console.Write("Hello");
else
Console.Write(" World!");
}
}
}
------解决方案--------------------