C#转VB

gzwlj2001 2015-02-07 02:02:35
public static implicit operator string[](StringList sl)
{
string[] sLHS = new string[sl.m_alMain.Count];
int index = 0;
while(index < sl.m_alMain.Count)
{
sLHS[index] = (string)sl.m_alMain[index];
index++;
}
return sLHS;
}

原代码如上,这是一个函数来是什么,如果是函数,函数名是什么,我用网上工具转成如下,不对、
Public Shared Widening Operator CType(ByVal sl As StringList) As String()
Dim sLHS As String() = New String(sl.m_alMain.Count - 1) {}
Dim index As Integer = 0
While index < sl.m_alMain.Count
sLHS(index) = DirectCast(sl.m_alMain(index), String)
index += 1
End While
Return sLHS
End Operator
...全文
145 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
gzwlj2001 2015-02-07
  • 打赏
  • 举报
回复
是不是VB.net2003不支持这个功能
gzwlj2001 2015-02-07
  • 打赏
  • 举报
回复
gzwlj2001 2015-02-07
  • 打赏
  • 举报
回复
你的意思是在vb里不需要这段代码,已经有现成的Ctype()了,是吗? 现在转换的这软件代码,在vb.net里会显示语法错误,谢谢!
本拉灯 2015-02-07
  • 打赏
  • 举报
回复
你不是发过了么。。 这是强制转换操作符重载 意思是 StringList 类型通过 (string[]) 这样的转换 类拟 string[] xxx=(string[])StringListxxx VB CType这是一个内部的方法名,是对的
wind_cloud2011 2015-02-07
  • 打赏
  • 举报
回复
http://blog.csdn.net/dzweather/article/details/9713097
wind_cloud2011 2015-02-07
  • 打赏
  • 举报
回复
http://vbcity.com/blogs/jatkinson/archive/2010/01/12/create-custom-types-and-initialize-them-without-the-new-keyword-c-vb-net.aspx
wind_cloud2011 2015-02-07
  • 打赏
  • 举报
回复

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧