Another problem with method override
Posted: May 28th, 2013, 9:50 am
Hi, referring to this post:
viewtopic.php?f=3&t=707&hilit=override
I have a similar problem with a method being called by a third one.
This is the php class:
I override the TestMethod in c# like this:
And this is the running example:
The problem is that the c# TestMethod() is not being called, I expected the result to be 9 but instead it's 7,
Many thanks,
Frank
viewtopic.php?f=3&t=707&hilit=override
I have a similar problem with a method being called by a third one.
This is the php class:
- Code: Select all
<?php
[\Export]
class Test
{
function __construct()
{
}
public function TestMethod()
{
return 5;
}
public function CallTestMethod()
{
$aa = $this->TestMethod();
$aa = $aa + 2;
return $aa;
}
public function RunTest()
{
return $this->CallTestMethod();
}
}
?>
I override the TestMethod in c# like this:
- Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PHP.Core;
namespace TestOverrideSharp
{
class TestOverrideSharpClass : Test
{
public override object TestMethod()
{
return 7;
}
}
}
And this is the running example:
- Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TestOverrideSharp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string s;
TestOverrideSharpClass c;
c = new TestOverrideSharpClass();
s = c.RunTest().ToString();
MessageBox.Show(s);
}
}
}
The problem is that the c# TestMethod() is not being called, I expected the result to be 9 but instead it's 7,
Many thanks,
Frank