keyword with in C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Elder Santos

    keyword with in C#

    hi, everyone,
    i would like know why c# doesn't have the keyword "with", such as vb does?

    Thank u so much;;


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.532 / Virus Database: 326 - Release Date: 27/10/2003


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: keyword with in C#

    Elder,

    It was determined that with doesn't add anything to the language in
    terms of readability (this is an opinion of the language designers). Also,
    "with" was used as a performance enhancement in VB, but in .NET, the
    mechanics are different, and the performance benefit is no longer there.
    Finally, given C#'s C/C++ heritage, those languages do not have a "with"
    statement, so this influenced the decision as well.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Elder Santos" <persondev@msn. com> wrote in message
    news:uQ%23Qm$un DHA.2732@TK2MSF TNGP11.phx.gbl. ..[color=blue]
    > hi, everyone,
    > i would like know why c# doesn't have the keyword "with", such as vb does?
    >
    > Thank u so much;;
    >
    >
    > ---
    > Outgoing mail is certified Virus Free.
    > Checked by AVG anti-virus system (http://www.grisoft.com).
    > Version: 6.0.532 / Virus Database: 326 - Release Date: 27/10/2003
    >
    >[/color]


    Comment

    • Jon Skeet [C# MVP]

      #3
      Re: keyword with in C#

      Elder Santos <persondev@msn. com> wrote:[color=blue]
      > i would like know why c# doesn't have the keyword "with", such as vb does?[/color]

      See http://www.gotdotnet.com/team/csharp.../ask.aspx#with
      and look back a few days in this very forum for discussion on it in a
      thread titled "With - End with block in C#".

      --
      Jon Skeet - <skeet@pobox.co m>
      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

      If replying to the group, please do not mail me too

      Comment

      • Brian W

        #4
        Re: keyword with in C#

        Is it me, or was this topic beaten to death already this week? (Oct-28 and
        Oct-29 to be specific, so it wouldn't have been too hard to see if the
        question had already been addressed)

        <sarcasm>

        People, could we limit the "why isn't C# more like VB.NET" questions to just
        one pert week? PLEASE!!!!! <bg>

        For future reference please see the following Q & A:

        Q: Why doesn't C# have (or do) <* Insert favorite VB feature here *> like
        VB?
        A: Because, C# is not VB!

        </sarcasm>


        Brian W


        "Elder Santos" <persondev@msn. com> wrote in message
        news:uQ%23Qm$un DHA.2732@TK2MSF TNGP11.phx.gbl. ..[color=blue]
        > hi, everyone,
        > i would like know why c# doesn't have the keyword "with", such as vb does?
        >
        > Thank u so much;;
        >
        >
        > ---
        > Outgoing mail is certified Virus Free.
        > Checked by AVG anti-virus system (http://www.grisoft.com).
        > Version: 6.0.532 / Virus Database: 326 - Release Date: 27/10/2003
        >
        >[/color]


        Comment

        • news.microsoft.com

          #5
          Re: keyword with in C#

          Ill never code VB and Ill never do webwhore stuff.

          Id rather do COBOL.

          VB = da piss



          "Brian W" <brianw@gold_de ath_2_spam_rush .com> wrote in message
          news:eYRkBxwnDH A.2312@TK2MSFTN GP12.phx.gbl...[color=blue]
          > Is it me, or was this topic beaten to death already this week? (Oct-28 and
          > Oct-29 to be specific, so it wouldn't have been too hard to see if the
          > question had already been addressed)
          >
          > <sarcasm>
          >
          > People, could we limit the "why isn't C# more like VB.NET" questions to[/color]
          just[color=blue]
          > one pert week? PLEASE!!!!! <bg>
          >
          > For future reference please see the following Q & A:
          >
          > Q: Why doesn't C# have (or do) <* Insert favorite VB feature here *> like
          > VB?
          > A: Because, C# is not VB!
          >
          > </sarcasm>
          >
          >
          > Brian W
          >
          >
          > "Elder Santos" <persondev@msn. com> wrote in message
          > news:uQ%23Qm$un DHA.2732@TK2MSF TNGP11.phx.gbl. ..[color=green]
          > > hi, everyone,
          > > i would like know why c# doesn't have the keyword "with", such as vb[/color][/color]
          does?[color=blue][color=green]
          > >
          > > Thank u so much;;
          > >
          > >
          > > ---
          > > Outgoing mail is certified Virus Free.
          > > Checked by AVG anti-virus system (http://www.grisoft.com).
          > > Version: 6.0.532 / Virus Database: 326 - Release Date: 27/10/2003
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Shawn B.

            #6
            Re: keyword with in C#

            I've many times examined the IL and the final x86 instructions of code made
            with "with" in VB.NET and it would appear that there are some optimizations,
            at least in the sense, that it assigns a pointer to a register and then the
            following uses of the with do some pointer magic with that register, as
            opposed to if I don't use the with, every use of the object causes it to
            fetch the pointer and then do some pointer magic. It appears there is an
            optimization.

            "With" is not a pure vb thing, as almost everyone thinks. It's also in
            JScript. Though the syntax of it in JScript is horrible, it doesn't use the
            preceding . (dot). It's never obvious when looking at the code. In VB,
            I've never had a problem with a "with". It does indeed add readibility to
            the code, an opinion no C# programmers share (probly because they aren't
            used to the grammer and they are so think on thinking "its a VB thing and I
            avoid all VB things.".

            My opinion is if you don't like/want "with" in C#, then plea with the
            language designers to get rid of the "using" statement as well.

            But the language must evolve, as does all other languages must evolve.
            Keeping features out of one just because they exist in another (one you
            don't like) is not a good enough reason to keep it out.

            I've read the papers from the C# developers explaining why they left it out
            and quite frankly, I've come to the conclusion that they won't do it because
            they are too lazy to add it in and because too many C# programmers feel it's
            a "VB thing" and despise it not based on any lack of merit. Everytime I've
            seen the argument, they are quick to point out something to the effect of
            "keep it in VB". They should say something to the effect of "keep it in VB,
            JScript, and JScript.NET". Because it's not just in VB.

            This topic has been pounded to death. I've written lengthy dissertations on
            the topic.

            I'm primarily an assembly language, C++ programmer who makes a living doing
            VB, who is good in C# and can do Java. Of all the languages I've worked
            with, I don't get "stuck" with any particular one. Each has its merits and
            its place and proper use. Just another tool in the toolbox. I don't mind
            language evolution. But I wouldn't fight toothe and nail to keep a feature
            out of a language just because its in an other language I don't want
            anything to do with.


            Thanks,
            Shawn


            "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
            message news:O50skGvnDH A.976@tk2msftng p13.phx.gbl...[color=blue]
            > Elder,
            >
            > It was determined that with doesn't add anything to the language in
            > terms of readability (this is an opinion of the language designers).[/color]
            Also,[color=blue]
            > "with" was used as a performance enhancement in VB, but in .NET, the
            > mechanics are different, and the performance benefit is no longer there.
            > Finally, given C#'s C/C++ heritage, those languages do not have a "with"
            > statement, so this influenced the decision as well.
            >
            > Hope this helps.
            >
            >
            > --
            > - Nicholas Paldino [.NET/C# MVP]
            > - mvp@spam.guard. caspershouse.co m
            >
            > "Elder Santos" <persondev@msn. com> wrote in message
            > news:uQ%23Qm$un DHA.2732@TK2MSF TNGP11.phx.gbl. ..[color=green]
            > > hi, everyone,
            > > i would like know why c# doesn't have the keyword "with", such as vb[/color][/color]
            does?[color=blue][color=green]
            > >
            > > Thank u so much;;
            > >
            > >
            > > ---
            > > Outgoing mail is certified Virus Free.
            > > Checked by AVG anti-virus system (http://www.grisoft.com).
            > > Version: 6.0.532 / Virus Database: 326 - Release Date: 27/10/2003
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Daniel O'Connell

              #7
              Re: keyword with in C#


              "Shawn B." <leabre@html.co m> wrote in message
              news:ufcWIJ0nDH A.744@tk2msftng p13.phx.gbl...[color=blue]
              > I've many times examined the IL and the final x86 instructions of code[/color]
              made[color=blue]
              > with "with" in VB.NET and it would appear that there are some[/color]
              optimizations,[color=blue]
              > at least in the sense, that it assigns a pointer to a register and then[/color]
              the[color=blue]
              > following uses of the with do some pointer magic with that register, as
              > opposed to if I don't use the with, every use of the object causes it to
              > fetch the pointer and then do some pointer magic. It appears there is an
              > optimization.
              >
              > "With" is not a pure vb thing, as almost everyone thinks. It's also in
              > JScript. Though the syntax of it in JScript is horrible, it doesn't use[/color]
              the[color=blue]
              > preceding . (dot). It's never obvious when looking at the code. In VB,
              > I've never had a problem with a "with". It does indeed add readibility to
              > the code, an opinion no C# programmers share (probly because they aren't
              > used to the grammer and they are so think on thinking "its a VB thing and[/color]
              I[color=blue]
              > avoid all VB things.".
              >
              > My opinion is if you don't like/want "with" in C#, then plea with the
              > language designers to get rid of the "using" statement as well.
              >[/color]

              Which using statement? I don't like using aliases, but I do like the using()
              statement, please qualify your statements fully.
              [color=blue]
              > But the language must evolve, as does all other languages must evolve.
              > Keeping features out of one just because they exist in another (one you
              > don't like) is not a good enough reason to keep it out.
              >
              > I've read the papers from the C# developers explaining why they left it[/color]
              out[color=blue]
              > and quite frankly, I've come to the conclusion that they won't do it[/color]
              because[color=blue]
              > they are too lazy to add it in and because too many C# programmers feel[/color]
              it's[color=blue]
              > a "VB thing" and despise it not based on any lack of merit. Everytime[/color]
              I've[color=blue]
              > seen the argument, they are quick to point out something to the effect of
              > "keep it in VB". They should say something to the effect of "keep it in[/color]
              VB,[color=blue]
              > JScript, and JScript.NET". Because it's not just in VB.
              >
              > This topic has been pounded to death. I've written lengthy dissertations[/color]
              on[color=blue]
              > the topic.
              >[/color]

              Yes it has, and its certainly not needed in C#, it was barely needed in VB
              or JScript, it is, at this point, just a syntax feature that doesn't provide
              much simplicity(and potentially could cause breaking simplicity, if used
              badly)
              [color=blue]
              > I'm primarily an assembly language, C++ programmer who makes a living[/color]
              doing[color=blue]
              > VB, who is good in C# and can do Java. Of all the languages I've worked
              > with, I don't get "stuck" with any particular one. Each has its merits[/color]
              and[color=blue]
              > its place and proper use. Just another tool in the toolbox. I don't mind
              > language evolution. But I wouldn't fight toothe and nail to keep a[/color]
              feature[color=blue]
              > out of a language just because its in an other language I don't want
              > anything to do with.
              >
              >
              > Thanks,
              > Shawn
              >
              >
              > "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote[/color]
              in[color=blue]
              > message news:O50skGvnDH A.976@tk2msftng p13.phx.gbl...[color=green]
              > > Elder,
              > >
              > > It was determined that with doesn't add anything to the language in
              > > terms of readability (this is an opinion of the language designers).[/color]
              > Also,[color=green]
              > > "with" was used as a performance enhancement in VB, but in .NET, the
              > > mechanics are different, and the performance benefit is no longer there.
              > > Finally, given C#'s C/C++ heritage, those languages do not have a "with"
              > > statement, so this influenced the decision as well.
              > >
              > > Hope this helps.
              > >
              > >
              > > --
              > > - Nicholas Paldino [.NET/C# MVP]
              > > - mvp@spam.guard. caspershouse.co m
              > >
              > > "Elder Santos" <persondev@msn. com> wrote in message
              > > news:uQ%23Qm$un DHA.2732@TK2MSF TNGP11.phx.gbl. ..[color=darkred]
              > > > hi, everyone,
              > > > i would like know why c# doesn't have the keyword "with", such as vb[/color][/color]
              > does?[color=green][color=darkred]
              > > >
              > > > Thank u so much;;
              > > >
              > > >
              > > > ---
              > > > Outgoing mail is certified Virus Free.
              > > > Checked by AVG anti-virus system (http://www.grisoft.com).
              > > > Version: 6.0.532 / Virus Database: 326 - Release Date: 27/10/2003
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              Working...