从方法返回 [英] Returns from a method

查看:84
本文介绍了从方法返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

原谅我,这可能是愚蠢的。我来自多年的视觉基础编程,并没有决定我想学习c#。我有什么似乎是一个简单的问题?我只是在玩简单的方法等,并希望简单地调用一个方法来生成,在这个例子中,
,单个字符串返回。我将字符串变量传递给我想要返回单个字符串的方法。即firstname,lastname to retrun fullname - firstname +" " +姓氏......我错过了什么... ????

命名空间ConsoleApplication4

{

   课程计划

    {

        static void Main(string [] args)

        {

解决方案

您需要指定方法的返回类型:

 private static 字符串 methodone(字符串名字,字符串姓氏)




Forgive me, this may be stupid. I come from many years of visual basic programming and have no decided I wish to learn c#. I have what seems to be a simple problem ?. I am just playing with simple methods etc and want to simply call a method to produce, in this example, a single string return. I am passing to string variables into a method which I want to return a single string. ie firstname, lastname to retrun fullname - firstname + " " + lastname……. what am I missing...????

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {

解决方案

You need to specify the return type of the method:

private static string methodone(string firstname, string lastname)



这篇关于从方法返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆