GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   ASP.NET C# Question (https://gfy.com/showthread.php?t=566394)

Validus 01-21-2006 09:35 AM

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 01-21-2006 09:36 AM

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

Validus 01-21-2006 09:40 AM

Quote:

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.

psili 01-21-2006 09:43 AM

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)

psili 01-21-2006 09:44 AM

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.

Validus 01-21-2006 09:46 AM

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

psili 01-21-2006 09:49 AM

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.

Validus 01-21-2006 09:57 AM

Quote:

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!

RocketFlow 01-21-2006 10:01 AM

Quote:

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

Validus 01-21-2006 10:12 AM

Quote:

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 :)

RocketFlow 01-21-2006 10:16 AM

Quote:

Originally Posted by Validus
Great, thanks to you as well... plug and play so to speak :)

Indeed! Best way to help people! :)


All times are GMT -7. The time now is 10:25 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123