Interfaces porting vb to c#

D

djohnson

I am trying to port vb code from the article "Another MultiForm Framework
for the Microsoft .NET Compact Framework" located on the OpenNetCF.org
website, http://www.opennetcf.org/articles/istack.asp.
I got as far as the formstack.vb and realized there are some differences
about how interfaces are used between vb and C# that I dont quite
understand.

this being the vb inteface (IStackable)
-----------------------------------------------------
Public Interface IStackable

'Updates the data contained in the form. This should be implemented on a per
form basis

Sub UpdateData()

'Returns the form itself.

Function This() As System.Windows.Forms.Form

'Calls InitializeComponents

Sub InitUI()

End Interface

----------------------------------------------------------------------------
---

I converted to c# as

----------------------------------------------------------------------------
---

using System;

namespace Achieve_PPC

{

/// <summary>

/// Interface for form cache

/// </summary>

public interface IStackable

{

//Updates the data contained in the form. This should be implemented on a
per form basis

void UpdateData();

//Returns the form itself.

Form This();

//Calls InitializeComponents

void InitUI();

}

}

----------------------------------------------------------------------------
------

Now, With this interface can someone explain why the c# cannot access
properties and methods of the interface "This()" method?

basically in vb the code does this...

<snip>----------------------------------------------------------------------
------------

Public Sub Push(ByVal frm As System.Type)

'Only allow 1 Push at a time to maintain cache and stack integrity

Monitor.Enter(Me)

For Each sf As IStackable In InnerList

If frm.Name = sf.This.GetType().Name Then
<===========sf.This.GetType().Name

'We had it cached - ask the form to update its data and display itself

sf.UpdateData()

sf.This.Visible = True

'Push it into the stack

stack.Add(frm.Name)

Return

End If

Next

<snip>----------------------------------------------------------------------
------------



In C# I cant access methods or properties of the interfaces' methods?

as such..

----------------------------------------------------------------------------
----------------

public void Push(Type FormType)

{

// only allow 1 Push at a time to maintain cache and stack itegrity

Monitor.Enter(this);

foreach(IStackable sf in List)

{

if(sf.GetType().Name.Equals(FormType.Name)) <===========CANNOT DO
"sf.This.GetType().Name" Any Idea Why?

{

// form is cached so display cached version

sf.Visible = true;

// add it to the stack

stack.Add(FormType.Name);

return;

}

}

_____________________________________________________



I Hope this makes sense, and I apreciate any help.

Thank You,

David Johnson
 
C

Chris Tacke, eMVP

Because the interface members must be marked as public. By default they'll
be private.

--
Chris Tacke, eMVP
Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net

djohnson said:
I am trying to port vb code from the article "Another MultiForm Framework
for the Microsoft .NET Compact Framework" located on the OpenNetCF.org
website, http://www.opennetcf.org/articles/istack.asp.
I got as far as the formstack.vb and realized there are some differences
about how interfaces are used between vb and C# that I dont quite
understand.

this being the vb inteface (IStackable)
-----------------------------------------------------
Public Interface IStackable

'Updates the data contained in the form. This should be implemented on a per
form basis

Sub UpdateData()

'Returns the form itself.

Function This() As System.Windows.Forms.Form

'Calls InitializeComponents

Sub InitUI()

End Interface

-------------------------------------------------------------------------- --
---

I converted to c# as

-------------------------------------------------------------------------- --
---

using System;

namespace Achieve_PPC

{

/// <summary>

/// Interface for form cache

/// </summary>

public interface IStackable

{

//Updates the data contained in the form. This should be implemented on a
per form basis

void UpdateData();

//Returns the form itself.

Form This();

//Calls InitializeComponents

void InitUI();

}

}

-------------------------------------------------------------------------- --
------

Now, With this interface can someone explain why the c# cannot access
properties and methods of the interface "This()" method?

basically in vb the code does this...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top