Foxtable(狐表)用户栏目专家坐堂 → [求助]Inherits 接口怎么来对接?


  共有4622人关注过本帖树形打印复制链接

主题:[求助]Inherits 接口怎么来对接?

帅哥哟,离线,有人找我吗?
浙江仔
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1325 积分:9586 威望:0 精华:1 注册:2010/7/21 14:20:00
[求助]Inherits 接口怎么来对接?  发帖心情 Post By:2022/11/17 9:37:00 [只看该作者]

C#代码转VB,结果出现了Inherits 接口,我改怎么去对接dll?
全局代码:
Namespace MAPIDemo
    Inherits XX.IStrList     '写在这里,提示:类只能从其他类继承
    Public Class MmForCSharp () As List
        Inherits IStrlist 'dll接口

        Public Function XX As List
            Return list
        End Function
    End Class
End Namespace

代码使用:
XX.StrList = New MmForCSharp()

全局代码中不写Inherits这句,则提示
无法将类型为“MmForCSharp”的对象强制转换为类型“XX.StrList”。


[此贴子已经被作者于2022/11/17 9:46:31编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:109505 积分:557193 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/11/17 9:49:00 [只看该作者]

C#代码发上来看看

 回到顶部
帅哥哟,离线,有人找我吗?
浙江仔
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1325 积分:9586 威望:0 精华:1 注册:2010/7/21 14:20:00
  发帖心情 Post By:2022/11/17 10:05:00 [只看该作者]

namespace MAPIDemo
{
    /// <summary>
    /// C#实现接口IFoldingStrategy
    /// </summary>
    public class MmForCSharp: IFoldingStrategy
    {
        public List<FoldMarker> GenerateFoldMarkers(IDocument document, string fileName, object parseInformation)
        {
            List<FoldMarker> list = new List<FoldMarker>();
            Stack<int> startLines = new Stack<int>();
            // Create foldmarkers for the whole document, enumerate through every line.
            for (int i = 0; i < document.TotalNumberOfLines; i++)
            {
                // Get the text of current line.
                string text = document.GetText(document.GetLineSegment(i));
                if (text.Trim().StartsWith("#region")) // Look for method starts
                {
                    startLines.Push(i);
                }
                if (text.Trim().StartsWith("#endregion")) // Look for method endings
                {
                    int start = startLines.Pop();
                    // Add a new FoldMarker to the list.
                    // document = the current document
                    // start = the start line for the FoldMarker
                    // document.GetLineSegment(start).Length = the ending of the current line = the start column of our foldmarker.
                    // i = The current line = end line of the FoldMarker.
                    // 7 = The end column
                    list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, 57, FoldType.Region, "..."));
                }
                //支持嵌套 {}
                if (text.Trim().StartsWith("{")) // Look for method starts
                {
                    startLines.Push(i);
                }
                if (text.Trim().StartsWith("}")) // Look for method endings
                {
                    if (startLines.Count > 0)
                    {
                        int start = startLines.Pop();
                        list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, 57, FoldType.TypeBody, "...}"));
                    }
                }
 
                // /// <summary>
                if (text.Trim().StartsWith("/// <summary>")) // Look for method starts
                {
                    startLines.Push(i);
                }
                if (text.Trim().StartsWith("/// <returns>")) // Look for method endings
                {
                    int start = startLines.Pop();
                    //获取注释文本(包括空格)
                    string display = document.GetText(document.GetLineSegment(start + 1).Offset, document.GetLineSegment(start + 1).Length);
                    //remove ///
                    display = display.Trim().TrimStart('/');
                    list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, 57, FoldType.TypeBody, display));
                }
            }
            return list;
        }
    }
}


或者如这种接口:
https://www.cnblogs.com/farrio/archive/2005/03/29/127917.html
[此贴子已经被作者于2022/11/17 10:06:09编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:109505 积分:557193 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/11/17 10:13:00 [只看该作者]

全局代码:

    Public Class MmForCSharp
        Implements IFoldingStrategy

        Public Function XX As List
            Return list
        End Function
    End Class

 回到顶部
帅哥哟,离线,有人找我吗?
浙江仔
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1325 积分:9586 威望:0 精华:1 注册:2010/7/21 14:20:00
  发帖心情 Post By:2022/11/17 13:38:00 [只看该作者]

感谢,实现了 

  Public Class MmForCSharp
        Implements IFoldingStrategy
        Public Function XX As List  Implements IFoldingStrategy.XX  这里也要加,XX的函数要和接口里面的函数对应
            Return list
        End Function
    End Class

 回到顶部