String vs string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • K Viltersten

    #16
    Re: String vs string

    Okay so something went missing in the post!

    Sorry i sounded agitated. My bad.
    I was just going to say that since C# type keywords are simplyaliases of
    the CLR types defined in the System namespace I'mnot aware that there is
    functionally any difference. In CLR ViaC# Jeffery Richter advocates
    using the CLR version but I can'trecall the reason without checking the
    book.
    Would be nice to hear what he's saying there. I don't have the
    book (read: i'm lazy)...
    As you go on to suggest I think that the only differences arein how you
    might want to work with the codebase in the future(i.e. language
    conversion) rather than how the codebase worksfunctional ly.
    Perhaps i made it sound like a bigger issue that what it was. My
    mistake, sorry. Anyhow, there seems to be a concensus that string
    type needs not to be capitalized so i'll be officially accepting
    that, effective monday next week. Thanks to everybody!

    --
    Regards
    Konrad Viltersten

    Comment

    • Jon Skeet [C# MVP]

      #17
      Re: String vs string

      K Viltersten <tmp1@vilterste n.comwrote:
      We have a similar argument at my company, I actually usestring and int
      rather than String and Int32 but the bestcase I can see for not using
      the alias is that it makesconverting to another CLR language such as
      VB.NET easier.
      >
      You're making an interesting point. I'm surprised that you
      put string/int in one basket and String/Int32 in an other.
      Um, why? string and int are both C#-specific shorthands. String/Int32
      are both the .NET type names. Seems logical to me.
      Please correct me if i've misunderstod the idea but i was
      told that that a string, being an object type, should be
      capitalized to String, while an integer, being value typed,
      deserves no such treatment.
      >
      Am i mistaken? Please elaborate.
      Yes, you're mistaken. I've never heard such a convention proposed
      before.

      As has been pointed out, there are plenty of value types which are
      capitalised: Point, DateTime, Guid etc.

      --
      Jon Skeet - <skeet@pobox.co m>
      Web site: http://www.pobox.com/~skeet
      Blog: http://www.msmvps.com/jon.skeet
      C# in Depth: http://csharpindepth.com

      Comment

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

        #18
        Re: String vs string

        K Viltersten wrote:
        At our company, we've been using the standard of string
        instead of String. While it's fullly compilable and
        valid code, i'd still claim that the type should be
        capitalized since it's an object type and not value
        type. That's my view.
        >
        My coworker is of a different opinion and he argues,
        and very rightfully so, that the development this far
        has used uncapitalized type and that it'll be
        unconvienient to change.
        >
        While i agree with his view as a pragmatical approach,
        i'd like to "give it to him" and argue to switch to
        capitalized type from now on.
        >
        Anybody willing to suggest a couple of good shots?
        The absolutely best would be a plan to abandon string
        and only support String in SOME future version of
        DotNet. Can i hope...?
        You can not hope.

        MS would never break so much code.

        There are no functional differences and will likely never be.

        The most important aspect is consistency within the project.

        So for an existing project you stick with what you have.

        For a new project you have a bit more freedom, but you
        should go with what is most commonly used.

        And my guess would be that string dominates over String
        like 75%-25%.

        (and int over Int32 at least 99.9%-0.1%)

        So I am backing your coworker.

        Arne

        Comment

        Working...