class hanshu { public void qiuhe(int n) { int sum = 0; for (int i = 0; i <= n; i++) { sum += i; } Console.Write("求和结果为"+sum); } static void Main(string[] args) { hanshu hs = new hanshu(); Console.Write("输入数字:"); int n = int.Parse(Console.ReadLine()); hs.qiuhe(n); Console.ReadLine(); } }
class Program { public string fanhuinihao() { return "你好"; } static void Main(string[] args) { Program fh=new Program(); string s = fh.fanhuinihao(); Console.Write(s); Console.ReadLine(); } }
class Program { public static string fanhuinihao(string s) { Console.Write(s); return "你好"; } static void Main(string[] args) { //Program fh=new Program(); fanhuinihao("你好"); string str = fanhuinihao("你好"); Console.Write(str); Console.ReadLine(); }
class Program { public static void fanhuinihao(string s) { Console.Write(s); } static void Main(string[] args) { //Program fh=new Program(); fanhuinihao("你好"); Console.ReadLine(); } }
class Program { public static void fanhuinihao() { Console.Write("你好"); } static void Main(string[] args) { //Program fh=new Program(); fanhuinihao(); Console.ReadLine(); } }