English 中文(简体)
C# 脚本 - 添加自定义类
原标题:C# Script - Adding Custom Class

I m making a script system and i need some help. I ve my class named Script.cs and my class named Person.cs.

person.cs 设置在第一个程序运行时(并且可以在执行期间再次设置)。 我要在我脚本上找到使用 person.cs 的方法, 请看 :

<强度 > 人/人.cs

//constructors

public string getName() { return m_name; }
public string getAge() { return m_age; }

< main > main.cs

//constructors
Person ps;
public void Run()
{
    ps = new Person("name", "10");
}

<% 1> < strong > Script.cs

剧本执行时,我怎么能对人做"跑跑"呢?

对不起,如果我表达得不好。

问题回答

我认为你正在寻找的是将 Run 改为 Main ,见 http://msdn.microsoft.com/en-us/library/acy3edy3(v=vs.71).aspx 。请确定设置您的工程以您的 Main 类作为切入点。

而且,看来Name Age 应该是 中的属性。见http://msdn.microsoft.com/ en-us/library/x9fsa0sw.aspx

您应该查看 < a href=> http://msdn.microsoft.com/ en- US/roslyn" rel= "nofollow" > Roslyn , 它允许您使用 C # 作为脚本语言。 这里的 < a href=> http://www.codeproject.com/ articles/11169/ C- As- A- Scripting- Language- In- Your- NET- Applications" rel= "nofollown" > CodeProject 文章 来启动您。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...