ASP.NET C# Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Validus
    Confirmed User
    • Jul 2001
    • 4012

    #1

    ASP.NET C# Question

    Thought I?d ask here, maybe some body knows.

    I want to shorten the value of a string to 50 characters. Any tips? Kind of like substr() in PHP?
  • psili
    Confirmed User
    • Apr 2003
    • 5526

    #2
    Don't know ASP or C#, but here's a google result for ya:
    http://www.aspmatrix.com/asp-net/str...g/substr2.aspx
    Your post count means nothing.

    Comment

    • Validus
      Confirmed User
      • Jul 2001
      • 4012

      #3
      Originally posted by psili
      Don't know ASP or C#, but here's a google result for ya:
      http://www.aspmatrix.com/asp-net/str...g/substr2.aspx

      Ah thanks a lot. Unfortunately it is VB not C#. I?ve been looking for a while now? just can?t seem to find anything. I must be on the wrong path.

      Comment

      • psili
        Confirmed User
        • Apr 2003
        • 5526

        #4
        It must be the same, since most low-level functions are across languages.
        Don't know where to search, but I'm sure VB has a "substring" function, where you put start position and end position.

        Edit: google knows all:

        Dim aString As String = "SomeString"
        Dim bString As String
        bString = Mid(aString, 3, 3)
        Your post count means nothing.

        Comment

        • psili
          Confirmed User
          • Apr 2003
          • 5526

          #5
          BTW, I've only played with VB a little bit and I can say I already hate that fucking language. But that's just personal opinion.
          Your post count means nothing.

          Comment

          • Validus
            Confirmed User
            • Jul 2001
            • 4012

            #6
            Yes.. but I am working with C# not VB.

            Comment

            • psili
              Confirmed User
              • Apr 2003
              • 5526

              #7
              K then.

              Done with helping this fucked up thread.

              I reply with an "ASP.NET C#" answer, and you say you're working in "VB". I reply with a "VB" solution and you say you're working in "C#".

              Do you know what the fuck you're doing, or am I just getting grumpy because I don't understand the question?

              btw, here's the C# example:

              String myString = "abc";
              bool test1 = String.Compare(myString.Substring(2, 1), "c") hahahaha 0; // This is true.
              myString.Substring(3, 1); // This throws ArgumentOutOfRangeException.
              bool test2 = String.Compare(myString.Substring(3, 0), String.Empty) hahahaha 0; // This is true.
              Your post count means nothing.

              Comment

              • Validus
                Confirmed User
                • Jul 2001
                • 4012

                #8
                Originally posted by psili
                K then.

                Done with helping this fucked up thread.

                I reply with an "ASP.NET C#" answer, and you say you're working in "VB". I reply with a "VB" solution and you say you're working in "C#".

                Do you know what the fuck you're doing, or am I just getting grumpy because I don't understand the question?

                btw, here's the C# example:

                String myString = "abc";
                bool test1 = String.Compare(myString.Substring(2, 1), "c") hahahaha 0; // This is true.
                myString.Substring(3, 1); // This throws ArgumentOutOfRangeException.
                bool test2 = String.Compare(myString.Substring(3, 0), String.Empty) hahahaha 0; // This is true.


                Thanks for your help!

                Comment

                • RocketFlow
                  Confirmed User
                  • Jun 2005
                  • 169

                  #9
                  Originally posted by Validus
                  Thought I?d ask here, maybe some body knows.

                  I want to shorten the value of a string to 50 characters. Any tips? Kind of like substr() in PHP?
                  Here is your example in C#:

                  Code:
                  String myLongString = "This is a very long text. This is a very long text. This is a very long text. This is a very long text. This is a very long text. This is a very long text. This is a very long text. ";
                  String myShortString = myLongString.Substring(0, 50);
                  HTH
                  RocketFlow.com - Premium Hosting Services - Unrivaled Speed, Unbeatable Service
                  ICQ #234-583-306 or 234-628-183

                  Comment

                  • Validus
                    Confirmed User
                    • Jul 2001
                    • 4012

                    #10
                    Originally posted by RocketFlow
                    Here is your example in C#:

                    Code:
                    String myLongString = "This is a very long text. This is a very long text. This is a very long text. This is a very long text. This is a very long text. This is a very long text. This is a very long text. ";
                    String myShortString = myLongString.Substring(0, 50);
                    HTH

                    Great, thanks to you as well... plug and play so to speak

                    Comment

                    • RocketFlow
                      Confirmed User
                      • Jun 2005
                      • 169

                      #11
                      Originally posted by Validus
                      Great, thanks to you as well... plug and play so to speak
                      Indeed! Best way to help people!
                      RocketFlow.com - Premium Hosting Services - Unrivaled Speed, Unbeatable Service
                      ICQ #234-583-306 or 234-628-183

                      Comment

                      Working...