请问,在VB.net转化为C#.net后,有一些语句没有完全转化过来,请问如何完全转化为C#
下面是FotoVision示例从VB.net转化为C#.net后的代码,不过仍然残留using Microsoft.VisualBasic;
其中object vector = Interaction.CreateObject( Consts.VectorProgId, "" ); 似乎是VB的语句,
请问如何完全转化为C#using System.Diagnostics;
using Microsoft.VisualBasic;
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Collections;// Uses the XP Photo Printing Wizard to print one or more photos.
// The implementation of the photo wizard is in photowiz.dll but the
// interface is not exposed. Instead, Microsoft provides the Windows
// Image Acquisition Library (WIA).
//
// Use late binding incase the user does not have the WIA component
// installed (and easier for developers to use the source if it's
// not installed).// use late binding for this source filenamespace FotoVision
{
public sealed class Print
{
// const values
private class Consts
{
public const string DialogProgId = "WIA.CommonDialog";
public const string VectorProgId = "WIA.Vector";
}

// static class
private Print() {
}

// public methods

// print the specified photo (full path to the photo)
public static void PrintFile (string file)
{
PrintFiles(new string[] {file});
}

// print the list of photos
public static void PrintFiles (Photo[] photos)
{
// convert to a string array
string[] files = new string[photos.Length-1 + 1];
for (int i = 0; i <= files.Length - 1; i++)
{
files[i] = photos[i].PhotoPath;
}
PrintFiles(files);
}

// print the list of files public static void PrintFiles (string[] files)
{
try
{
// create the vector COM object
object vector = Interaction.CreateObject(Consts.VectorProgId, "");

// add files to the vector object
foreach (string file in files)
{
System.Diagnostics.vector.Add(file);
}

// create the common dialog COM object, and
// display the photo print wizard
object dialog = Interaction.CreateObject(Consts.DialogProgId, "");
dialog.ShowPhotoPrintingWizard(vector);

vector = null;
dialog = null;
}
catch (Exception ex)
{
Global.DisplayError("The photo could not be printed.", ex);
}
}

}

}

解决方案 »

  1.   

    Microsoft.VisualBasic;
    其中object vector = Interaction.CreateObject( Consts.VectorProgId, "" ); 
    ----------------------------------------------------------------------------
    不懂vb,这个做什么的?
      

  2.   

    Microsoft.VisualBasic;
    其中object vector = Interaction.CreateObject( Consts.VectorProgId, "" ); 
    是VB语句,不过俺从来没有用过,一开始都用vb.net.
      

  3.   

    你添加vb引用,也可以在C#里面使用VB代码。