C# 部分类使用partial修饰

时间:2022-05-13 08:35:20
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace patial
{
class Program
{
static void Main(string[] args)
{ Student s = new Student();
s.Method2();
Console.ReadKey();
}
} public partial class Student
{
private int _age; public void Method1()
{
Console.WriteLine("method1");
}
} public partial class Student
{
public void Method2()
{
///调用部分类中的私有属性
_age = ;
Console.WriteLine("method2");
Console.WriteLine(_age);
} }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace patial
{
class Program
{
static void Main(string[] args)
{ Student s = new Student();
s.Method2();
Console.ReadKey();
}
} public partial class Student
{
private int _age; public void Method1()
{
Console.WriteLine("method1");
}
} public partial class Student
{
public void Method2()
{
///调用部分类中的私有属性
_age = ;
Console.WriteLine("method2");
Console.WriteLine(_age);
} }
}