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. The Lounge
  3. Fine, I'll jump on the "I hate Microsoft" bandwagon

Fine, I'll jump on the "I hate Microsoft" bandwagon

Scheduled Pinned Locked Moved The Lounge
67 Posts 26 Posters 2 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.
  • M Mark_Wallace

    RyanDev wrote:

    Don't give me workarounds when all I want to do is complain.

    i confess that that is something that grandly pisses me off.

    RyanDev wrote:

    I know it's super simple to write one myself, but the point is I should not have to.

    It's that it was taken away because some moron decided for you that you didn't need it; that's what gets the teeth grinding.

    I wanna be a eunuchs developer! Pass me a bread knife!

    D Offline
    D Offline
    Deflinek
    wrote on last edited by
    #16

    Guys, you are aware that features are unimplemented by default[^], right?

    -- "My software never has bugs. It just develops random features."

    M 1 Reply Last reply
    0
    • D Deflinek

      Guys, you are aware that features are unimplemented by default[^], right?

      -- "My software never has bugs. It just develops random features."

      M Offline
      M Offline
      Mark_Wallace
      wrote on last edited by
      #17

      But it was implemented. I'm now recompiling everything I've ever written in C#, to insert workarounds. It's a very happy job, as I'm sure you can imagine.

      I wanna be a eunuchs developer! Pass me a bread knife!

      1 Reply Last reply
      0
      • M Mark_Wallace

        Yup. Phones getting bigger, having to press a button to see the time on your watch, having to write your own extensions... The seventies are back, for certain.

        I wanna be a eunuchs developer! Pass me a bread knife!

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #18

        Quote:

        The seventies are back, for certain.

        Except for the music! There is no music anymore! X|

        Get me coffee and no one gets hurt!

        M W 2 Replies Last reply
        0
        • Z ZurdoDev

          Um what? Microsoft.VisualBasic. And it's still there.

          There are only 10 types of people in the world, those who understand binary and those who don't.

          M Offline
          M Offline
          Mark_Wallace
          wrote on last edited by
          #19

          On the VB tab, it gives the VB syntax:

          Public Shared Function Left (
          str As String,
          Length As Integer
          ) As String

          On the C# tab, it gives the C# syntax:

          public static string Left(
          string str,
          int Length
          )

          I know that computery things seem complicated, Granny, but you ought to at least try to use them.

          I wanna be a eunuchs developer! Pass me a bread knife!

          Z 1 Reply Last reply
          0
          • L Lost User

            Quote:

            The seventies are back, for certain.

            Except for the music! There is no music anymore! X|

            Get me coffee and no one gets hurt!

            M Offline
            M Offline
            Mark_Wallace
            wrote on last edited by
            #20

            Oh, there is, but the definition of the word "music" has changed to be something to do with money for nothing.

            I wanna be a eunuchs developer! Pass me a bread knife!

            L M 2 Replies Last reply
            0
            • M Mark_Wallace

              On the VB tab, it gives the VB syntax:

              Public Shared Function Left (
              str As String,
              Length As Integer
              ) As String

              On the C# tab, it gives the C# syntax:

              public static string Left(
              string str,
              int Length
              )

              I know that computery things seem complicated, Granny, but you ought to at least try to use them.

              I wanna be a eunuchs developer! Pass me a bread knife!

              Z Offline
              Z Offline
              ZurdoDev
              wrote on last edited by
              #21

              You're still missing what namespace the function is in. :doh:

              There are only 10 types of people in the world, those who understand binary and those who don't.

              M 1 Reply Last reply
              0
              • M Mark_Wallace

                Is there a chapter and verse that gives a get-out from wearing flares and an afro?

                I wanna be a eunuchs developer! Pass me a bread knife!

                Kornfeld Eliyahu PeterK Offline
                Kornfeld Eliyahu PeterK Offline
                Kornfeld Eliyahu Peter
                wrote on last edited by
                #22

                Maybe...

                Deuteronomy 22, 5:

                A woman shall not wear that which pertaineth unto a man, neither shall a man put on a woman's garment...

                Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.

                "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

                M 1 Reply Last reply
                0
                • Z ZurdoDev

                  You're still missing what namespace the function is in. :doh:

                  There are only 10 types of people in the world, those who understand binary and those who don't.

                  M Offline
                  M Offline
                  Mark_Wallace
                  wrote on last edited by
                  #23

                  Don't bother me with petty details when I'm in panic mode! Looks like I've always used Substring, anyway. Strange, that. It feels like I've used Left much more recently than I've used VB. {Insert Sid James comment here]

                  I wanna be a eunuchs developer! Pass me a bread knife!

                  1 Reply Last reply
                  0
                  • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

                    Maybe...

                    Deuteronomy 22, 5:

                    A woman shall not wear that which pertaineth unto a man, neither shall a man put on a woman's garment...

                    Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.

                    M Offline
                    M Offline
                    Mark_Wallace
                    wrote on last edited by
                    #24

                    That's close enough for me!

                    I wanna be a eunuchs developer! Pass me a bread knife!

                    1 Reply Last reply
                    0
                    • Z ZurdoDev

                      So, C# has no left method on a string? :omg: :omg: It would be so easy to add one, lazy Microsoft C# developers. So, use substring. Whoops. Nope. Errors if you give it a length that is longer than the string. I miss VB. :sigh:

                      There are only 10 types of people in the world, those who understand binary and those who don't.

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #25

                      RyanDev wrote:

                      I miss VB. :sigh:

                      ..a special place in Hell.

                      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                      1 Reply Last reply
                      0
                      • M Mark_Wallace

                        Oh, there is, but the definition of the word "music" has changed to be something to do with money for nothing.

                        I wanna be a eunuchs developer! Pass me a bread knife!

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #26

                        Quote:

                        the definition of the word "music" has changed to be something to do with money for nothing

                        You nailed it! In a few words you nailed it! Modern music is nothing and worth nothing! Now: How are we going to convince poor souls like Sander that this is true? :-D

                        Get me coffee and no one gets hurt!

                        M 1 Reply Last reply
                        0
                        • L Lost User

                          Quote:

                          the definition of the word "music" has changed to be something to do with money for nothing

                          You nailed it! In a few words you nailed it! Modern music is nothing and worth nothing! Now: How are we going to convince poor souls like Sander that this is true? :-D

                          Get me coffee and no one gets hurt!

                          M Offline
                          M Offline
                          Mark_Wallace
                          wrote on last edited by
                          #27

                          I'd suggest a 22oz Estwing and a bunch of four-inch nails.

                          I wanna be a eunuchs developer! Pass me a bread knife!

                          1 Reply Last reply
                          0
                          • Z ZurdoDev

                            So, C# has no left method on a string? :omg: :omg: It would be so easy to add one, lazy Microsoft C# developers. So, use substring. Whoops. Nope. Errors if you give it a length that is longer than the string. I miss VB. :sigh:

                            There are only 10 types of people in the world, those who understand binary and those who don't.

                            G Offline
                            G Offline
                            glennPattonWork3
                            wrote on last edited by
                            #28

                            Quote:

                            I miss VB.

                            Well someone has to, I suppose...

                            1 Reply Last reply
                            0
                            • S Scott Serl

                              Here you go:

                                  public static string Left(this string theString, int length)
                                  {
                                      int sz = length > theString.Length + 1 ? theString.Length:length;
                              
                                      return theString.Substring(0, sz);
                                  }
                              
                              Richard DeemingR Offline
                              Richard DeemingR Offline
                              Richard Deeming
                              wrote on last edited by
                              #29

                              No need to call Substring if the length is greater than (or equal to) the string's length. And you'll get a NullReferenceException if the string is null, whereas VB would return an empty string instead. Seems like an odd choice, but when you're pandering to these VB devs... :rolleyes:

                              public static string Left(this string theString, int length)
                              {
                              if (length < 0) throw new ArgumentOutOfRangeException(nameof(length));
                              if (theString == null || length == 0) return string.Empty;
                              if (theString.Length <= length) return theString;
                              return theString.Substring(0, length);
                              }

                              Now, let's hope he doesn't ask for a C# version of this VB6 abomination:

                              Dim s As String = "He11o"
                              Mid$(s, 3, 2) = "ll"


                              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                              "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                              1 Reply Last reply
                              0
                              • 9 9082365

                                RyanDev wrote:

                                Errors if you give it a length that is longer than the string.

                                As one would jolly well hope it did. I don't see why MS should take stick for your faulty programming logic.

                                I am not a number. I am a ... no, wait!

                                D Offline
                                D Offline
                                dandy72
                                wrote on last edited by
                                #30

                                Well, he did mention VB. Which teaches everyone bad habits.

                                S 1 Reply Last reply
                                0
                                • Z ZurdoDev

                                  So, C# has no left method on a string? :omg: :omg: It would be so easy to add one, lazy Microsoft C# developers. So, use substring. Whoops. Nope. Errors if you give it a length that is longer than the string. I miss VB. :sigh:

                                  There are only 10 types of people in the world, those who understand binary and those who don't.

                                  S Offline
                                  S Offline
                                  Super Lloyd
                                  wrote on last edited by
                                  #31

                                  Oh my, you are the quick to hate type, are you not? One tiny method missing and *boom* I hate you MS! That escalated rather quickly! :O At any rate I give you here, free of charge, a solution to use for your own coding pleasure! No, no, no, there is no need to thank me!

                                  public static class StringExtensions {
                                  public static string Left(this string s, int n) {
                                  if (n >= s.Length)
                                  return "";
                                  return s.Substring(s.Length - n);
                                  }
                                  }

                                  All in one Menu-Ribbon Bar DirectX for WinRT/C# since 2013! Taking over the world since 1371!

                                  J D Z 3 Replies Last reply
                                  0
                                  • Z ZurdoDev

                                    So, C# has no left method on a string? :omg: :omg: It would be so easy to add one, lazy Microsoft C# developers. So, use substring. Whoops. Nope. Errors if you give it a length that is longer than the string. I miss VB. :sigh:

                                    There are only 10 types of people in the world, those who understand binary and those who don't.

                                    B Offline
                                    B Offline
                                    BillWoodruff
                                    wrote on last edited by
                                    #32

                                    While I cherish the myriad weirdnesses I am aware of in my long-term relationship with C#, the absence of 'Left would not qualify. Welcome to Linq: [^]. Unless there's something you just can't stand about the word: "Take" ? :) cheers, Bill

                                    «There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008

                                    1 Reply Last reply
                                    0
                                    • Z ZurdoDev

                                      So, C# has no left method on a string? :omg: :omg: It would be so easy to add one, lazy Microsoft C# developers. So, use substring. Whoops. Nope. Errors if you give it a length that is longer than the string. I miss VB. :sigh:

                                      There are only 10 types of people in the world, those who understand binary and those who don't.

                                      M Offline
                                      M Offline
                                      Marc Clifton
                                      wrote on last edited by
                                      #33

                                      These are the string extension methods I wrote ages ago (well, since extension methods have been around): (Note that some of this isn't very elegant, could be LINQ'ified, could be optimized, etc.)

                                      	/// /// Returns a new string surrounded by single quotes.
                                      	/// 
                                      	public static string SingleQuote(this String src)
                                      	{
                                      		return "'" + src + "'";
                                      	}
                                      
                                      	/// /// Returns a new string surrounded by quotes.
                                      	/// 
                                      	public static string Quote(this String src)
                                      	{
                                      		return "\\"" + src + "\\"";
                                      	}
                                      
                                      	/// /// Exchanges ' for " and " for '
                                      	/// Javascript JSON support, which must be formatted like '{"foo":"bar"}'
                                      	/// 
                                      	public static string ExchangeQuoteSingleQuote(this String src)
                                      	{
                                      		string ret = src.Replace("'", "\\0xFF");
                                      		ret = ret.Replace("\\"", "'");
                                      		ret = ret.Replace("\\0xFF", "\\"");
                                      
                                      		return ret;
                                      	}
                                      
                                      	/// /// Returns the source string surrounded by a single whitespace.
                                      	/// 
                                      	public static string Spaced(this String src)
                                      	{
                                      		return " " + src + " ";
                                      	}
                                      
                                      	/// /// Returns a new string surrounded by brackets.
                                      	/// 
                                      	public static string Parens(this String src)
                                      	{
                                      		return "(" + src + ")";
                                      	}
                                      
                                      	/// /// Returns a new string surrounded by brackets.
                                      	/// 
                                      	public static string Brackets(this String src)
                                      	{
                                      		return "\[" + src + "\]";
                                      	}
                                      
                                      	/// /// Returns a new string surrounded by brackets.
                                      	/// 
                                      	public static string CurlyBraces(this String src)
                                      	{
                                      		return "{" + src + "}";
                                      	}
                                      
                                      	/// /// Returns everything between the start and end chars, exclusive.
                                      	/// 
                                      	/// The source string.
                                      	/// The first char to find.
                                      	/// The end char to find.
                                      	/// The string between the start and stop chars, or an empty string if not found.
                                      	public static string Between(this string src, char start, char end)
                                      	{
                                      		string ret = String.Empty;
                                      		int idxStart = src.IndexOf(start);
                                      
                                      		if (idxStart != -1)
                                      		{
                                      			++idxStart;
                                      			int idxEnd = src.IndexOf(end, idxStart);
                                      
                                      			if (idxEnd != -1)
                                      			{
                                      				ret = src.Substring(idxStart, idxEnd - idxStart);
                                      			}
                                      		}
                                      
                                      		return ret;
                                      	}
                                      
                                      	public static string Between(this string src, string start, string end)
                                      	{
                                      		string ret = String.Empty;
                                      		int idxStart = src.IndexOf(start);
                                      
                                      		if (idxSta
                                      
                                      1 Reply Last reply
                                      0
                                      • M Mark_Wallace

                                        Oh, there is, but the definition of the word "music" has changed to be something to do with money for nothing.

                                        I wanna be a eunuchs developer! Pass me a bread knife!

                                        M Offline
                                        M Offline
                                        Marco Bertschi
                                        wrote on last edited by
                                        #34

                                        Mark_Wallace wrote:

                                        money for nothing

                                        And chicks for free.

                                        D 1 Reply Last reply
                                        0
                                        • S Scott Serl

                                          Here you go:

                                              public static string Left(this string theString, int length)
                                              {
                                                  int sz = length > theString.Length + 1 ? theString.Length:length;
                                          
                                                  return theString.Substring(0, sz);
                                              }
                                          
                                          J Offline
                                          J Offline
                                          Jono Stewart
                                          wrote on last edited by
                                          #35

                                          Don't forget the null check! And a small tweak because I like doing it this way :P It's called Truncate in my library, but if you're from VB, I guess Left is ok... Or you could just reference the Microsoft.VisualBasic assembly!

                                          public static string Left(this string target, int length)
                                          {
                                          if(string.IsNullOrEmpty(target) //could just do == null; condition below caters to empty (which is faster I wonder)
                                          return target;

                                          return target.SubString(0, Math.Min(target.Length, length));
                                          

                                          }

                                          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