473,241 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

Please help convert the following Java to C#

Please help me convert the following Java to C#

class ProgramChoice {
private Class cls;
private String text;

ProgramChoice(String text, Class cls) {
this.cls = cls;
this.text = text;
}

public String toString() { return text; }
Class value() { return cls; }
}

Any help will be greatly appreciated.
Charles
Aug 24 '08 #1
6 1220
Charles wrote:
Please help me convert the following Java to C#

class ProgramChoice {
private Class cls;
private String text;

ProgramChoice(String text, Class cls) {
this.cls = cls;
this.text = text;
}

public String toString() { return text; }
Class value() { return cls; }
}

Any help will be greatly appreciated.
I would say something like:

internal class ProgramChoice
{
private Type cls;
private string text;

internal ProgramChoice(string text, Type cls) {
this.cls = cls;
this.text = text;
}

public override string ToString()
{
return text;
}

internal Type Value
{
get { return cls; }
}
}

Java default/package and .NET internal is not the exact same,
but will do in many cases.

Arne
Aug 24 '08 #2
"Charles" <Ch*****@discussions.microsoft.comwrote:
Please help me convert the following Java to C#
I think it would be what you see below. I've prepended an underscore to
field names according to C# naming conventions.

Eq.
class ProgramChoice
{
private object _cls;
private string _text;

public ProgramChoice(string text, object cls)
{
_cls = cls;
_text = text;
}

public override string ToString()
{
return _text;
}

public object Value
{
get { return _cls; }
}
}
Aug 24 '08 #3
"Paul E Collins" <fi******************@CL4.orgwrote:
I've prepended an underscore to field names according to C# naming
conventions.
Curses, I was getting mixed up with something else, wasn't I? Apologies. I
don't think C# has any such convention.

Eq.
Aug 24 '08 #4
Paul E Collins wrote:
"Paul E Collins" <fi******************@CL4.orgwrote:
>I've prepended an underscore to field names according to C# naming
conventions.

Curses, I was getting mixed up with something else, wasn't I? Apologies. I
don't think C# has any such convention.
Some people do use _ prefix, but it is not a majority.

Arne
Aug 24 '08 #5
No need to get undies bundled. The underscore is a common prefixed notation
convention as is m_ which you can see Dino Esposito use as well as others
who picked up the habit to visually decorate text to give it a visual
property where the language itself and all other conventions lack such
characteristics. However while such conventions are cononical they are not
found in the official language specifications. Which is why people made them
up in the first place.

I was an architect and we use dozens of symbolic references to indicate type
in the same context as we do when decorating OOP. I've been wondering lately
how we will map them to the OOP objects they describe now that OOP has
become the defacto way to model objects.

"Arne Vajhøj" <ar**@vajhoej.dkwrote in message
news:48***********************@news.sunsite.dk...
Paul E Collins wrote:
>"Paul E Collins" <fi******************@CL4.orgwrote:
>>I've prepended an underscore to field names according to C# naming
conventions.

Curses, I was getting mixed up with something else, wasn't I? Apologies.
I don't think C# has any such convention.

Some people do use _ prefix, but it is not a majority.

Arne
Aug 24 '08 #6
HillBilly wrote:
No need to get undies bundled. The underscore is a common prefixed
notation convention as is m_ which you can see Dino Esposito use as well
as others who picked up the habit to visually decorate text to give it a
visual property where the language itself and all other conventions lack
such characteristics. However while such conventions are cononical they
are not found in the official language specifications. Which is why
people made them up in the first place.
It is not that widely used.

One reason could be that the official MS design guide explicit
recommends not using prefixes in field names.

Arne
Aug 24 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dan | last post by:
Hello, I am trying to read and write to an Excel file via my Java applet. I have done so successfully on several simple Excel files that simply had data cells without many complicated equations...
1
by: kaiwing18 | last post by:
Hi , I have a problem relate to java and database. Could anyone answer me ?Please see the following code. import java.sql.*; public class Result { public static void main(String args) {
1
by: Az Tech | last post by:
Hi people, (Sorry for the somewhat long post). I request some of the people on this group who have good experience using object-orientation in the field, to please give some good ideas for...
1
by: Jens Mueller | last post by:
Hi there, this is a Java-XML Question, so I am not sure whether this is the right place, haven't found anything better .... I try to convert a Java object to XML via SAX and let the FOP...
1
by: sachin | last post by:
hello everyone, i am trying to convert my XSL-FO to PDF file by using fop-0.20.5 by importing the following classes: import java.io.File; import java.io.IOException; import...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
1
by: al mwaj3 | last post by:
please I need help in this problem, I must send it tomorrow the problem is (1) Write a Java class called: Binary that has two data fields: an integer array, and an integer size as well as the...
4
by: =?Utf-8?B?Q2hhcmxlcw==?= | last post by:
Hello all, I'm trying to convert a Java Genetic Programming program to C#. I don't know how to convert the following Java code: Object choice = functionSet.getSelectedItem(choice)).value();...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.