夜光序言:
人再完美,精神也需要知音;心在坚强,情感也需要慰藉。
人生路上,没有人能够单独走完一生,都需要友情相伴。
正文:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 内部类测试1
{
class Y
{
}
/// <summary>
/// 我们定义一个X内部类
/// </summary>
class X
{
//定义一些公共的变量参数
public int i;
public float a;
public bool b;
public string c;
public Y y;
}
/// <summary>
/// 夜光:先定义一个A
/// </summary>
class A
{
int i = 1111;//默认是私有的private
public class B
{
//写一个方法
public int GetAI(A a)
{
return a.i; //这样写会不会报错?嗯唔
}
}
/* public B CreateB()
{
return new B();
}*/
}
class Program
{
static void Main(string[] args)
{
//new一下
A a = new A();
X x = new X();
Console.WriteLine(x.a);
Console.WriteLine(x.i);
Console.WriteLine(x.b);
Console.WriteLine(x.c);
Console.WriteLine(x.y);
// a.CreateB();
A.B b = new A.B();
int ai =b.GetAI(a);
Console.WriteLine(ai);
Console.ReadLine();
}
}
}