Please help convert the following Java to C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Q2hhcmxlcw==?=

    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(S tring 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
  • =?UTF-8?B?QXJuZSBWYWpow7hq?=

    #2
    Re: Please help convert the following Java to C#

    Charles wrote:
    Please help me convert the following Java to C#
    >
    class ProgramChoice {
    private Class cls;
    private String text;
    >
    ProgramChoice(S tring 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(s tring 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

    Comment

    • Paul E Collins

      #3
      Re: Please help convert the following Java to C#

      "Charles" <Charles@discus sions.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(s tring text, object cls)
      {
      _cls = cls;
      _text = text;
      }

      public override string ToString()
      {
      return _text;
      }

      public object Value
      {
      get { return _cls; }
      }
      }


      Comment

      • Paul E Collins

        #4
        Re: Please help convert the following Java to C#

        "Paul E Collins" <find_my_real_a ddress@CL4.orgw rote:
        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.


        Comment

        • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

          #5
          Re: Please help convert the following Java to C#

          Paul E Collins wrote:
          "Paul E Collins" <find_my_real_a ddress@CL4.orgw rote:
          >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

          Comment

          • HillBilly

            #6
            Re: Please help convert the following Java to C#

            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" <arne@vajhoej.d kwrote in message
            news:48b0b62a$0 $90274$14726298 @news.sunsite.d k...
            Paul E Collins wrote:
            >"Paul E Collins" <find_my_real_a ddress@CL4.orgw rote:
            >>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

            Comment

            • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

              #7
              Re: Please help convert the following Java to C#

              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

              Comment

              Working...