在文件里面定义一个类,并进行实例化为对象
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloWorld { class Recttest { public String test = "My string test"; public void Testfun() { Console.WriteLine("Hello world2"); } } class HelloApp { static void Main(string[] args) { Console.WriteLine("Hello world1"); Recttest r = new Recttest(); r.Testfun(); Console.WriteLine("test=" + r.test); Console.ReadKey(); } } }
时间: 2024-12-19 06:53:48