我有一个叫做“打印"的类而且我有一种称为"printfile"的方法.我必须在prolog .net文件中调用该方法. [英] i have a class called "Print" and in that i have a method called "printfile". and i have to call that method in prolog .net file.

查看:76
本文介绍了我有一个叫做“打印"的类而且我有一种称为"printfile"的方法.我必须在prolog .net文件中调用该方法.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个叫做"Print"的类,并且有一个叫做"printfile"的方法.而且我必须在prolog .net文件中调用该方法.

这是示例代码:

i have a class called "Print" and in that i have a method called "printfile". and i have to call that method in prolog .net file.

here is the sample code:

public class Print
{
       public Print()
       {
           //code
       }
       public static void printfile(string at)
       {
           StreamWriter w = new StreamWriter("c:\filetest.txt", true);
           w.WriteLine(at);
           w.Close();
       }
}



然后我将该类转换为.dll并在prolog .net类中使用.

prolog .net类别:



then i convert this class in .dll and uses in prolog .net class.

prolog .net class:

assembly(''print.dll'').

:-class(''Test'').


testfile:-''Print''::''printfile''(''test'').


但是当我执行此操作时,它给出错误对象引用未设置为对象的实例"

请告诉我我应该怎么做...


but when i execute this it gives error "Object reference is not set to an instance of an object"

please tell me what should i do...

推荐答案

我的猜测是您要么必须实例化Print对象,要么必须创建方法静态.

我什至不知道那里是否有* Prolog.Net ...
My guess is that you either have to instantiate your Print object, or you have to make the PrintFile method static.

I didn''t know there even *was* a Prolog.Net...


为什么要定义printfile方法,然后尝试调用Writefile方法?
:)
Why do you define a printfile method and then you try to call a Writefile one?
:)


确定,尝试使用此


testfile(X):-object(''print'',Objt),invoke(Objt,''printfile''(X)).
ok try with this


testfile(X):-object(''print'',Objt), invoke(Objt,''printfile''(X)).


这篇关于我有一个叫做“打印"的类而且我有一种称为"printfile"的方法.我必须在prolog .net文件中调用该方法.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆