C#中直接调用VB.NET的函数,兼论半角与全角、简繁体中文互相转化
在C#项目中添加引用Microsoft.VisualBasic.dll, 可以在C#程序中直接使用VB.NET中丰富的函数 程序输出:
1
// 命令行编译 : csc /r:Microsoft.VisualBasic.dll Test.cs
2![](https://skyiv.cnblogs.com/Images/OutliningIndicators/None.gif)
3
// 如果是用 Visual Studio .NET IDE, 请按以下方法为项目添加引用:
4
// 打开[解决方案资源管理器], 右击项目名称, 选择[添加引用],
5
// 从列表中选择 Microsoft Visual Basic .NET Runtime 组件.
6![](https://skyiv.cnblogs.com/Images/OutliningIndicators/None.gif)
7
using Microsoft.VisualBasic;
8![](https://skyiv.cnblogs.com/Images/OutliningIndicators/None.gif)
9
class Test
10
{
11
static void Main()
12
{
13
string s = "博客园-空军 [skyIV.cnBlogs.com]";
14
System.Console.WriteLine(s);
15
s = Strings.StrConv(s, VbStrConv.Wide , 0); // 半角转全角
16
s = Strings.StrConv(s, VbStrConv.TraditionalChinese, 0); // 简体转繁体
17
System.Console.WriteLine(s);
18
s = Strings.StrConv(s, VbStrConv.ProperCase , 0); // 首字母大写
19
s = Strings.StrConv(s, VbStrConv.Narrow , 0); // 全角转半角
20
s = Strings.StrConv(s, VbStrConv.SimplifiedChinese , 0); // 繁体转简体
21
System.Console.WriteLine(s);
22
}
23
}
博客园-空军 [skyIV.cnBlogs.com]
博客園-空軍 [skyIV.cnBlogs.com]
博客园-空军 [Skyiv.Cnblogs.Com]
http://www.66169.com/soft.php?id=1016277
1
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/None.gif)
10
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
11
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
12
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
13
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
14
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
15
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
16
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
20
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
23
![](https://skyiv.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
博客园-空军 [skyIV.cnBlogs.com]
博客園-空軍 [skyIV.cnBlogs.com]
博客园-空军 [Skyiv.Cnblogs.Com]
http://www.66169.com/soft.php?id=1016277