简单语法,方法的定义~
本章介绍一些简单语法。
数据结构,条件语句,循环语句。。没什么好说的,具体看下面完整代码吧
public static:简单定义一个方法~
例如这里定义了一个加法~
public static int AddNumber(int a, int b)
{
return a + b;
}
以下是完整sample02~
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sample02
{
internal class Program
{
static void Main(string[] args)
{
int number = 10; //数据类型。
float decimalNum = 3.14f;
string nanme = "Jhon";
bool isTrue = true;
int result = number + 5; //简单赋值
result *= 2;
Console.WriteLine("Result:" + result);
if (result > 20) //简单判断
{
Console.WriteLine("more than 20");
}
else if (result > 10)
{
Console.WriteLine("more than 10");
}else
{
Console.WriteLine("less than 20");
}
for(int i = 0; i < 5; i++) //简单循环
{
Console.WriteLine("i is " + i);
}
int sum = AddNumber(3, 4);
Console.WriteLine("sum = " + sum);
Console.ReadLine();
}
public static int AddNumber(int a, int b)
{
return a + b;
}
}
}
标签:Console,int,平台,System,result,WriteLine,using,程序设计,NET
From: https://www.cnblogs.com/nekodream/p/17208427.html