C# syntax question

B

B. Chernick

I'm trying to translate a C# class to VB (Dot Net 2.0). I am not all that
familiar with C#. This C# class implements the IDataReader interface.

In C#, when a class implements an interface that specifies a readonly
property, does C# care whether that readonly property is implemented as a
readonly property or as a method, so long as it has the correct name and
return type?
 
J

Jon Skeet [C# MVP]

B. Chernick said:
I'm trying to translate a C# class to VB (Dot Net 2.0). I am not all that
familiar with C#. This C# class implements the IDataReader interface.

In C#, when a class implements an interface that specifies a readonly
property, does C# care whether that readonly property is implemented as a
readonly property or as a method, so long as it has the correct name and
return type?

Yes, it has to be a property.
 
S

Sachin Pise

Hello B. Chernick,
I'm trying to translate a C# class to VB (Dot Net 2.0). I am not all
that familiar with C#. This C# class implements the IDataReader
interface.

In C#, when a class implements an interface that specifies a readonly
property, does C# care whether that readonly property is implemented
as a readonly property or as a method, so long as it has the correct
name and return type?


Try this. Very easy and helps 90% in most cases.
http://labs.developerfusion.co.uk/convert/csharp-to-vb.aspx

Regards,
Sachin
 
B

B. Chernick

Yes, that's one of the tools I've been using, although I think SharpDevelop
is more useful for converting whole projects.
 
B

B. Chernick

It's possible my confusion may be due to a glitch in the translator or Visual
Studio.

If I remember correctly, when I translated this class, the output contained
(more or less) a batch of correctly named functions to match the interface
and also a batch of readonly properties with matching names but with an added
'1' at the end. And these properties had the Implements
System.Data.IDataReader.<method name> statement.

Had to fix it manually.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top