?
Solved

VB.NET to C#

Posted on 2005-03-28
6
Medium Priority
?
351 Views
Last Modified: 2010-04-16
Hi,
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


0
Comment
Question by:sunilramu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 9

Expert Comment

by:zaghaghi
ID: 13648455
hi,
you can use Type dotnetframework's class:

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

have a good programming day;
--hamed
0
 

Author Comment

by:sunilramu
ID: 13648512
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??

0
 
LVL 9

Expert Comment

by:zaghaghi
ID: 13648528
try this:
if ( typeof(oFileUp.Form(iterator.Current)) == SaFile.GetType())
0
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!

 
LVL 9

Accepted Solution

by:
zaghaghi earned 2000 total points
ID: 13648587
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:

http://www.elegancetech.com/CSVB_Download.aspx

0
 

Author Comment

by:sunilramu
ID: 13648745
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.
0
 
LVL 9

Expert Comment

by:zaghaghi
ID: 13648870
thank for correct answer ;)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month12 days, 10 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question