C#开发.NET应用程序的步骤

下载Visual studio
新建C#项目
使用C#编写代码
编译运行

C#源程序文件、vs解决方案文件、Web项目文件、C#项目文件的后缀名

浅学C#(4)——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#(4)——C#基础

C#编程基础

变量类型

浅学C#(4)——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};

相关文章:

  • 2021-08-19
  • 2021-09-02
  • 2021-05-06
  • 2022-12-23
  • 2021-05-27
  • 2021-09-15
  • 2021-11-06
  • 2022-12-23
猜你喜欢
  • 2021-07-04
  • 2022-12-23
  • 2021-07-08
  • 2021-12-25
  • 2022-01-08
  • 2021-11-11
  • 2021-08-20
相关资源
相似解决方案