C# 调用 Microsoft.VisualBasic.Collection
d.Add("Northsnow")
d.Add("塞北的雪")
d.Add("http://blog.csdn.net")
Dim t As New ArrayList(d)
Dim sb As New System.Text.StringBuilder()
If t.Count > 0 Then
sb.Append("ArrayList中共有 成员 ")
sb.Append(t.Item(2).ToString)
sb.Append(" 个")
For Each aa As String In t
sb.AppendLine()
sb.Append(aa)
Next
End If
MsgBox(sb.ToString)
以上是使用ARRAYLIST存储一个集合,VB中可以使用collectin,将其传入arraylist,而在C#中如何定义这个东西,使他能够传入ARRAYLIST呢?给个例子,谢谢
http://community.csdn.net/Expert/TopicView3.asp?id=5655091
解决
// 事实上你可以直接在 C# 中使用 Microsoft.VisualBasic.Collection
// 需要添加对 Microsoft.VisualBasic.dll 的引用
Microsoft.VisualBasic.Collection d = new Microsoft.VisualBasic.Collection();
d.Add("Northsnow", null, null, null); // C# 不支持可选参数, 若不指定 传入 null
d.Add("塞北的雪", null, null, null);
d.Add("http://blog.csdn.net", null, null, null);
ArrayList t = new ArrayList(d);
StringBuilder sb = new System.Text.StringBuilder();
if (t.Count > 0) {
sb.Append("ArrayList中共有 成员 ");
sb.Append(t.Count.ToString());
sb.Append(" 个");
}
foreach (string aa in t) {
sb.AppendLine();
sb.Append(aa);
}
2。
以上代码比较适合将进行 VB.net 向 C# 的直接移植,
因为
Visual Basic 集合与 System.Collections、System.Collections.Generic 和 System.Collections.Specialized 命名空间中的 .NET Framework 集合不兼容
具体没有实践过,不知道是否会导致后期维护的困难。
3。
若新项目,最佳实践实现是,使用 System.Collection.ArrayList
ArrayList list1 = new ArrayList();
list1.Add("a");
list1.Add("b");
ArrayList list2 = new ArrayList(list1);
补充
// using System.Collections.Generic;
IList<int> list2 = new List<int>(2);
list2.Add(119);
list2.Add(911);
//
Visual Basic Collection 类 http://msdn2.microsoft.com/zh-cn/library/microsoft.visualbasic.collection(VS.80).aspx
总结
1. .NET 果然跨语言^_^
2. 由于语言特性本身的差异,需要注意对特定语法支持,特别是开发类库的时候
3. 为保证语言的兼容性和互操作性,尽可能选择非特定语言支持的类库,而使用 System 命名空间及其子命名空间的类
转载于:https://www.cnblogs.com/Jinglecat/archive/2007/07/17/821824.html
C# 调用 Microsoft.VisualBasic.Collection相关推荐
- C#对Microsoft.VisualBasic My对象兰台妙选【月儿原创】
C#对Microsoft.VisualBasic My对象兰台妙选 作者:清清月儿 主页:http://blog.csdn.net/21aspnet/ 时间:2007.4.24 ...
- [入门]C#语法里面,如何使用 VB的常用函数?(using Microsoft.VisualBasic)
这里是我的文章备份 原文请看: http://www.dotblogs.com.tw/mis2000lab/archive/2011/10/24/46162.aspx [入门]C#语法里面,如何使用 ...
- C#对Microsoft.VisualBasic My对象兰台妙选
转自:http://tmsoft.lsxy.com/index.php?load=read&id=224 1.添加引用 2.引用Microsoft.VisualBasic 命名空间 3.所有的 ...
- 调用Microsoft.Jet.OLEDB.4.0需要MDAC2.7支持
asp.net进行Excel导入时需要调用Microsoft.Jet.OLEDB.4.0 strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data S ...
- C#调用Microsoft.DirectX.DirectSound问题记录及解决
C#调用Microsoft.DirectX.DirectSound问题记录及解决 参考文章: (1)C#调用Microsoft.DirectX.DirectSound问题记录及解决 (2)https: ...
- 利用Microsoft.VisualBasic dll来修改系统时间
C# 里面貌似没有什么好的方法 用WMI会Access Denied,用VB成功. Code using System; using Microsoft.VisualBasic; namespace ...
- C 对Microsoft VisualBasic My对象兰台妙选【月儿原创】
分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! C#对M ...
- [导入]C#对Microsoft.VisualBasic My对象兰台妙选【月儿原创】
C#对Microsoft.VisualBasic My对象兰台妙选[月儿原创] 文章来源:http://blog.csdn.net/21aspnet/archive/2007/04/24/157682 ...
- python request microsoft graph_从Azure函数内部调用Microsoft Graph API
我正在尝试编写一个调用Microsoft Graph API的简单Azure函数.但是我无法使access_token工作.这是我所做的: 通过Azure门户创建了一个新的Azure Function ...
最新文章
- 怎么理解linux的平均负载及平均负载高后的排查工具
- [云炬创业基础笔记]第二章创业者测试21
- 云炬随笔20210803
- vscode 里 Import “numpy“ count not be resolved
- 中国最神秘的一所大学,它只存在过8年,却成了永远的第一
- java 签名 ecdsa_Java实现ECDSA签名算法
- 笔试常见的“阶乘”编程题,你写对了么?
- 前端项目,将package.json数据放到项目某处使用
- 手机版python3.8.1下载_python3.8.1汉化版
- 小米max刷鸿蒙,用了小米Max2,这简直是浪费我一天一夜的时间!
- 2007 word打开无响应
- 《研究生英语科技论文写作》学习笔记
- Java未来城市练习代码01
- Xutils上传图片(2)
- 3.摄像模组之Golden模组
- Sigmoid函数解析
- Matplotlib数据可视化基础
- dillo支持html5吗,流动聚焦及射流不稳定性
- python数据结构之数据类型
- openwrt篇修改WiFi热点默认名称和主机名
热门文章
- android程序到处apk,导出已安装到手机中程序的apk文件
- LeetCode 100. 相同的树 思考分析
- Java BigDecimal longValueExact()方法与示例
- Java InputStreamReader getEncoding()方法及示例
- 置换元素和非置换元素_循环置换数组元素的C程序
- 实训09.09:简单的彩票系统(机选多注)
- python xml etree_python解析xml文件之xml.etree.cElementTree和xml.etree.ElementTree区别和基本使用...
- 466. 统计重复个数 golang[转]
- CRC冗余校验举例和原理
- 函数无法识别_PostgreSQL找不到最佳函数问题解析