nbsp;的用户定义类型
接口只包含方法、属性、事件或索引器的签名。 实现接口的类或结构必须实现接口定义中指定的接口成员。
实例:
interface ISampleInterface //只定义声明
{
void SampleMethod();
}
class ImplementationClass : ISampleInterface
{
// Explicit interface member implementation: (具体的方法实现在类中实现)
void ISampleInterface.SampleMethod()
{
// Method implementation.(方法代码)
}
static void Main()
{
// Declare an interface instance.
ISampleInterface obj = new ImplementationClass();
// Call the member.
obj.SampleMethod();
}
}
3. 数组类型
一维和多维,例如 int[] 和 int[,]
可以将同一类型的多个变量存储在一个数组数据结构中。 通过指定数组的元素类型来声明数组。
class TestArraysClass
{
static void Main()
{
// Declare a single-dimensional array.
int[] array1 = new int[5];
// Declare and set array element values.
int[] array2 = new int[] { 1, 3, 5, 7, 9 };
// Alternative syntax.
int[] array3 = { 1, 2, 3, 4, 5, 6 };
// Declare a two dimensional array.
int[,] multiDimensionalArray1 = new int[2, 3];
// Declare and set array element values.
int[,] multiDimensionalArray2 = { { 1, 2, 3 }, { 4, 5, 6 } };
// Declare a jagged array.
int[][] jaggedArray = new int[6][];
// Set the values of the first array in the jagged array structure.
jaggedArray[0] = new int[4] { 1, 2, 3, 4 };
}
}
4. 委托类型
格式为 delegate int D(...) 的用户定义类型
具体参考:事件与委托学习笔记03
https://www.cnblogs.com/asahiLikka/p/11644393.html