看板Programming
标 题Re: 请问一下这一段C#该如何转成VB.Net?
发信站不良牛牧场 (Sun Sep 23 01:14:15 2007)
转信站ptt!ctu-reader!ctu-gate!news.nctu!news.ntu!news.au!zoonews.ee.ntu!SimF
我不知道是否有工具可以直接对转C# & VB.NET, 但是我知道有个工具
可以解析 MSIL 对应到任何.NET的语言, 包括C#, VB.NET, Delphi.NET...etc.
你可以搜寻 .Net Reflector 这个程式.
但是由於它属於Disassembler(反组译器), 且用MSIL当转译的Source.
所以你必须先将C#程式编译成组件Assembly後再用它来反组译成 VB.NET.
听起来是有点脱裤子放屁的味道啦...
但这只是我的经验分享.
※ 引述《[email protected] (大改名片档)》之铭言:
: 请问是否有软体可以协助转换呢?
: 不过我想我应该要多了解C#写法了
: 附上语法,烦请协助,谢谢!
: using System;
: using System.Drawing;
: using System.Runtime.InteropServices;
: namespace C2C.FileSystem
: {
: public class ShellIcon
: {
: [StructLayout(LayoutKind.Sequential)]
: public struct SHFILEINFO
: {
: public IntPtr hIcon;
: public IntPtr iIcon;
: public uint dwAttributes;
: [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
: public string szDisplayName;
: [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
: public string szTypeName;
: };
: class Win32
: {
: public const uint SHGFI_ICON = 0x100;
: public const uint SHGFI_LARGEICON = 0x0; // 'Large icon
: public const uint SHGFI_SMALLICON = 0x1; // 'Small icon
: [DllImport("shell32.dll")]
: public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes,
: ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags);
: }
: public ShellIcon()
: {
: //
: // TODO: Add constructor logic here
: //
: }
: public static Icon GetSmallIcon(string fileName)
: {
: IntPtr hImgSmall; //the handle to the system image list
: SHFILEINFO shinfo = new SHFILEINFO();
: //Use this to get the small Icon
: hImgSmall = Win32.SHGetFileInfo(fileName, 0, ref shinfo,(uint)Marshal.SizeOf(shi
: nfo),Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON);
: //The icon is returned in the hIcon member of the shinfo struct
: return System.Drawing.Icon.FromHandle(shinfo.hIcon);
: }
: public static Icon GetLargeIcon(string fileName)
: {
: IntPtr hImgLarge; //the handle to the system image list
: SHFILEINFO shinfo = new SHFILEINFO();
: //Use this to get the large Icon
: hImgLarge = Win32.SHGetFileInfo(fileName, 0, ref shinfo, (uint)Marshal.SizeOf(sh
: info), Win32.SHGFI_ICON | Win32.SHGFI_LARGEICON);
: //The icon is returned in the hIcon member of the shinfo struct
: return System.Drawing.Icon.FromHandle(shinfo.hIcon);
: }
: }
: }
--
╭──── Origin:
<不良牛牧场> bbs.badcow.com.tw (210.200.247.200)─────╮
│ ↘ Welcome to SimFarm BBS -- From : [220.138.41.202] │
╰◣◣◢ ◢◢《不良牛免费拨接→电话:40586000→帐号:zoo→密码:zoo》 ◣◣◢ ─╯