版权声明:转载请注明出处 https://blog.csdn.net/le_17_4_6/article/details/86557581
C#开发.NET应用程序的步骤
下载Visual studio
新建C#项目
使用C#编写代码
编译运行
C#源程序文件、vs解决方案文件、Web项目文件、C#项目文件的后缀名
第一个简单的C#应用程序
新建一个控制台应用程序
using System;
using System.Collections.Generic;
using System.Text;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
C#编程基础
变量类型
System.Array的属性与方法
System.Array是所有数组类型的抽象基类型,所有的数组类型均由它派生,任何数组都可以使用System.Array具有的属性及方法
- Length属性可以获取数组的长度
- GetLength(n)方法可以得到第n维的数组长度
- Sort方法可以对数组按升序排列
- Reverse方法把数组中的元素反序
一维数组的声明、创建、初始化
const int size = 4;
float[] fs = new float[size];
//初始化方式1
for (int i = 0; i < fs.Length; i++)
fs[i] = (float) 2007.0/(i+1);
//初始化2
float[] fs = new float4[4] {1.0, 2.0, 3.0, 4.0};
//3
float[] fs = new float4[] {1.0, 2.0, 3.0, 4.0};
//4
float[] fs = {1.0, 2.0, 3.0, 4.0};