小白求教方法问题

ztdsg 2011-02-27 07:54:31

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
class Program
{
static void hello(int d,int e)
{
int c = d * e ;
hello(2,3);
Console.WriteLine(c);
}

static void Main(string[] args)
{

}
}
}

我新学c#,希望大家不要吝惜指教。为什么运行后,控制台上神马数字都没有?
...全文
70 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ztdsg 2011-02-27
  • 打赏
  • 举报
回复
谢谢ls的了,其实我只是想随便试一下怎么调用方法= =b,已经可以了
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
class Program
{
static int hello(int d,int e)
{
int c = d * e;
return c;
}

static void Main(string[] args)
{

Console.WriteLine("result is : " + hello (2,3) );
}
}
}
xuzysun 2011-02-27
  • 打赏
  • 举报
回复
Main方法里都没有调用
hhaayy2002 2011-02-27
  • 打赏
  • 举报
回复
Main 是主入口,你要在main中调用 hello才行
claymore1114 2011-02-27
  • 打赏
  • 举报
回复
你想 做什么?? Main方法里都没有调用,你的 hello(2,3); 是不是应该写到 入口Main函数里头。
枪牌 2011-02-27
  • 打赏
  • 举报
回复
static void hello(int d,int e)
{
int c = d * e ;
Console.WriteLine(c);
hello(2,3);
}

这样就有输出了,不过不知道你到底想写个什么


另外默认是从Main进入程序的,也就是说默认情况下你增加了hello方法,但是什么都没执行
不知道你是不是设置了


ztdsg 2011-02-27
  • 打赏
  • 举报
回复
那应该怎么改呢?[Quote=引用 1 楼 wuyq11 的回复:]
死循环
static void hello(int d,int e)
{
return d * e ;
}
[/Quote]
wuyq11 2011-02-27
  • 打赏
  • 举报
回复
死循环
static void hello(int d,int e)
{
return d * e ;
}

110,567

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧