Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 353
  • Last Modified:

VB.NET to C#

I have a sample code in VB.NET which I am converting to C#. I am using Softartisans FileUp and XFile to upload file to webserver.

Here is the part of VB.NET code

 1) Dim oFileUp As New FileUp(Me.Context)
 2) Dim iterator As SaUploadDictionaryEnum
 3) iterator = CType(oFileUp.Form.GetEnumerator(), SaUploadDictionaryEnum)
 4) If TypeOf oFileUp.Form(iterator.Current) Is SaFile Then
 5) End If

I am converting the above code to C#......I am stuck at line 4(If TypeOf oFileUp.Form(iterator.Current) Is SaFile Then). I don't know how to convert line 4 in C#.....
I converted first 3 lines as follows and it worked, but I am stuck at line 4.

FileUp oFileUp = new FileUp(Context);                  
SaUploadDictionaryEnum iterator;
iterator = oFileUp.Form.GetEnumerator() as SaUploadDictionaryEnum;

So what I need is just equivalent of (If TypeOf oFileUp.Form(iterator.Current) Is SaFile Then) in C#.

Thanks in advance

  • 4
  • 2
1 Solution
Hamed ZaghaghiProgrammerCommented:
you can use Type dotnetframework's class:

if ( typeof(oFileUp.Form[iterator.Current]) == SaFile.GetType())

have a good programming day;
sunilramuAuthor Commented:
I tried that but is says syntax error near iterator.
I am using the following line somewhere else in the code and it works fine.
SaFile oFile = oFileUp.Form[iterator.Current] as SaFile;

But when I use
if ( typeof(oFileUp.Form[iterator.Current]) == SaFile.GetType())
it gives syntax error near iterator..says ..... Syntax error, ']' expected

Any comments??

Hamed ZaghaghiProgrammerCommented:
try this:
if ( typeof(oFileUp.Form(iterator.Current)) == SaFile.GetType())
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hamed ZaghaghiProgrammerCommented:
if previous code didn't work, use C-Sharpener for VB Trial version,, and convert your vb project to C# and then if you want to know what is the conversion of these line, look in cs code,

you can download C-Sharpener for VB from this link:


sunilramuAuthor Commented:
The correct syntax was this:
if ( oFileUp.Form[ iterator.Current ] is SaFile )

I used the C-Sharpener for converting the VB.NET project to C#. Although there were minor problems with the converted code, I got my answer. Thanks Hamed for fast reply.
Hamed ZaghaghiProgrammerCommented:
thank for correct answer ;)

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now