| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 694 人关注过本帖
标题:[求助]为什么这里要有return
取消只看楼主 加入收藏
hanxuema
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2006-7-28
收藏
 问题点数:0 回复次数:0 
[求助]为什么这里要有return

using System;

class Class1
{
public static void Main()
{
string command;

while ((command = Console.ReadLine()) != "exit")
{
switch (command)
{
case "get":
doget();
break;

case "put":
doput();
break;

case "default":
doDefault();
break;
}
}
}

public static int doget()
{
Console.WriteLine("get is ok");
return 0;
}

public static int doput()
{
Console.WriteLine("put is ok");
return 0;
}
private static int doDefault()
{
Console.WriteLine("the command is wrong");
Console.WriteLine("whileApp V0.1 supprts:");
Console.WriteLine("\tget:\t");
Console.WriteLine("\tput:\t");
Console.WriteLine("\texit:\t");

return 0;
}
}



关于这个程序,请问在 public static int doget()
{
Console.WriteLine("get is ok");
return 0;
}中为什么一定要return 0; 我不写return好像不行,请问是为什么,错误报告说需要一个int,谁能详细解释一下,因为为什么要public static int doget 里面的这个int 我都不知道

或者return 100可以吗?

谢谢大家

搜索更多相关主题的帖子: return 
2006-08-11 03:03
快速回复:[求助]为什么这里要有return
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.010913 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved