C Sharp中的功能 [英] Functions in C Sharp

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

问题描述

如何在C#中声明函数?

How do I declare functions in C#?

推荐答案

开始 ^ ]读取所有内容.
Start here[^] read everything.


所有函数都是类的一部分,通常称为方法.

All functions are part of a class, they''re usually called methods.

private/public int myMethod (int param);



此方法将一个int作为输入并返回一个int.

干杯



This method takes an int as input and returns an int.

Cheers


[修饰符] [返回类型] [功能名称](parm)
{
//在这里编写代码
}

public int add(int a,int b)
{
int sum = a + b;
返回总和;
}
[modifier] [return type] [founction name](parm)
{
// write code here
}
ie
public int add(int a,int b)
{
int sum=a+b;
return sum;
}


这篇关于C Sharp中的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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