Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Go to Hell

Go to Hell

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpcomsalestutorialquestion
10 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kunal Chowdhury IN
    wrote on last edited by
    #1

    Here I came to a code, which looks like a Horror Movie of C#:

    public bool IsMatched(string str)
    {
    if(str.ToString().Equals("Customer"))
    {
    return true;
    }
    return false;
    }

    What this means? Is it really require? Go to hell.

    Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.


    Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial

    A K 2 Replies Last reply
    0
    • K Kunal Chowdhury IN

      Here I came to a code, which looks like a Horror Movie of C#:

      public bool IsMatched(string str)
      {
      if(str.ToString().Equals("Customer"))
      {
      return true;
      }
      return false;
      }

      What this means? Is it really require? Go to hell.

      Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.


      Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial

      A Offline
      A Offline
      ARopo
      wrote on last edited by
      #2

      Does that compile? or should it be public bool IsMatched(string str). If it is a bool then this function does the same as if (str=="Customer") maybe they wanted to write

      public bool IsCustomer(string str)
      {
      return (str=="Customer");
      }

      K 1 Reply Last reply
      0
      • A ARopo

        Does that compile? or should it be public bool IsMatched(string str). If it is a bool then this function does the same as if (str=="Customer") maybe they wanted to write

        public bool IsCustomer(string str)
        {
        return (str=="Customer");
        }

        K Offline
        K Offline
        Kunal Chowdhury IN
        wrote on last edited by
        #3

        Yes, it's "public bool". My point here is in this line: if(str.ToString().Equals("Customer")) What is the significance of doing ToString() in a string? I am going mad... :mad: Ahh!!! Why people does this ToString() in a string variable?

        Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.


        Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial

        A 1 Reply Last reply
        0
        • K Kunal Chowdhury IN

          Yes, it's "public bool". My point here is in this line: if(str.ToString().Equals("Customer")) What is the significance of doing ToString() in a string? I am going mad... :mad: Ahh!!! Why people does this ToString() in a string variable?

          Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.


          Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial

          A Offline
          A Offline
          ARopo
          wrote on last edited by
          #4

          no point, but it doesn't do any harm other than making the code slightly less readable. Also no need to call Equals directly could call ==

          A J 2 Replies Last reply
          0
          • A ARopo

            no point, but it doesn't do any harm other than making the code slightly less readable. Also no need to call Equals directly could call ==

            A Offline
            A Offline
            AspDotNetDev
            wrote on last edited by
            #5

            ARopo wrote:

            it doesn't do any harm

            Unless the string happens to be null.

            [Forum Guidelines]

            1 Reply Last reply
            0
            • K Kunal Chowdhury IN

              Here I came to a code, which looks like a Horror Movie of C#:

              public bool IsMatched(string str)
              {
              if(str.ToString().Equals("Customer"))
              {
              return true;
              }
              return false;
              }

              What this means? Is it really require? Go to hell.

              Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.


              Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial

              K Offline
              K Offline
              Khaniya
              wrote on last edited by
              #6

              It's not very big thing as your subject suggested

              Life's Like a mirror. Smile at it & it smiles back at you.- P Pilgrim So Smile Please

              I 1 Reply Last reply
              0
              • A ARopo

                no point, but it doesn't do any harm other than making the code slightly less readable. Also no need to call Equals directly could call ==

                J Offline
                J Offline
                Jammer 0
                wrote on last edited by
                #7

                Possible operator overload??

                Jammer My Blog | Articles | DMon | SampleSort

                1 Reply Last reply
                0
                • K Khaniya

                  It's not very big thing as your subject suggested

                  Life's Like a mirror. Smile at it & it smiles back at you.- P Pilgrim So Smile Please

                  I Offline
                  I Offline
                  icestatue
                  wrote on last edited by
                  #8

                  I got one better. The other developer here wrote: DataRow Dr; if( ((string)Dr["Col"]).ToString() != "false") return true; else return false; The biggest problem is that the value was stored in the database as a non nullable boolean value. She also wrote a stored proc that was more than 265 pages or roughly 5 megs worth of code. She didn't know how to write a query to test for null parameter so she wrote one query for ever parameter combination for the procedure that had 10 parameters. So effectively 2^10 number of combinations. I hope someone dumps her sorry behind, she gives programmers a bad name.

                  nothing

                  H 1 Reply Last reply
                  0
                  • I icestatue

                    I got one better. The other developer here wrote: DataRow Dr; if( ((string)Dr["Col"]).ToString() != "false") return true; else return false; The biggest problem is that the value was stored in the database as a non nullable boolean value. She also wrote a stored proc that was more than 265 pages or roughly 5 megs worth of code. She didn't know how to write a query to test for null parameter so she wrote one query for ever parameter combination for the procedure that had 10 parameters. So effectively 2^10 number of combinations. I hope someone dumps her sorry behind, she gives programmers a bad name.

                    nothing

                    H Offline
                    H Offline
                    Hired Mind
                    wrote on last edited by
                    #9

                    icestatue wrote:

                    a stored proc that was more than 265 pages or roughly 5 megs worth of code

                    Bah!!!! Please tell me that is a typo. If not, lie to me please, or my head may explode. And our cleaning people have asked that I not do that any more, as they hate cleaning brain out of my office. I can't even deal with 256 *line* sprocs, much less 256 pages.

                    Before .NET 4.0, object Universe = NULL;

                    I 1 Reply Last reply
                    0
                    • H Hired Mind

                      icestatue wrote:

                      a stored proc that was more than 265 pages or roughly 5 megs worth of code

                      Bah!!!! Please tell me that is a typo. If not, lie to me please, or my head may explode. And our cleaning people have asked that I not do that any more, as they hate cleaning brain out of my office. I can't even deal with 256 *line* sprocs, much less 256 pages.

                      Before .NET 4.0, object Universe = NULL;

                      I Offline
                      I Offline
                      icestatue
                      wrote on last edited by
                      #10

                      Afraid not, those numbers are correct. ....I'll bring the mop!:~

                      nothing

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups