一条vb.net语句 转换成 C#语句
来源:百度知道 编辑:UC知道 时间:2024/05/14 15:48:54
vb.net 语句 Dim Asm As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
转换成C#语句为:
System.Reflection.Assembly Asm = new System.Reflection.Assembly()上述转化哪里有错误?
我在VB.NET 里边语句如上正常运行. C#里边 提示错误.
错误 1 类型“System.Reflection.Assembly”未定义构造函数 D:\5Report\InstallerP.cs 27 46 5Report
如果转换后为以下:
System.Reflection.Assembly Asm = new System.Reflection.Assembly.GetExecutingAssembly();
错误 11 “System.Reflection.Assembly.GetExecutingAssembly()”是“方法”,但此处被当做“类型”来使用 D:\5Report\InstallerP.cs 63 77 5Report
请写出正确的C# 语句,如果我的第二种方法是正确的,请问问题出在哪里?
转换成C#语句为:
System.Reflection.Assembly Asm = new System.Reflection.Assembly()上述转化哪里有错误?
我在VB.NET 里边语句如上正常运行. C#里边 提示错误.
错误 1 类型“System.Reflection.Assembly”未定义构造函数 D:\5Report\InstallerP.cs 27 46 5Report
如果转换后为以下:
System.Reflection.Assembly Asm = new System.Reflection.Assembly.GetExecutingAssembly();
错误 11 “System.Reflection.Assembly.GetExecutingAssembly()”是“方法”,但此处被当做“类型”来使用 D:\5Report\InstallerP.cs 63 77 5Report
请写出正确的C# 语句,如果我的第二种方法是正确的,请问问题出在哪里?
MSDN上面Assembly类的说明很完整了
System.Reflection.Assembly Asm =System.Reflection.Assembly.GetExecutingAssembly(); 就可以
最好是开头那里使用
using System;
using System.Reflection;
这样就能写成这样了
Assembly Asm = Assembly.GetExecutingAssembly();
System.Reflection.Assembly Asm = System.Reflection.Assembly.GetExecutingAssembly(); 这个绝对正确
给你个网站专门从VB转换成C#的,很好用的
http://www.developerfusion.com/tools/convert/vb-to-csharp/
System.Reflection.Assembly Asm = new System.Reflection.Assembly.GetExecutingAssembly();
把那个 new 去掉就好了.
System.Reflection.Assembly Asm =System.Reflection.Assembly.GetExecutingAssembly();
GetExecutingAssembly()方法是静态方法 不能用New关键字