Click here to Skip to main content
13,001,514 members (57,723 online)
Rate this:
Please Sign up or sign in to vote.
See more:
string places very important role in c#
i just want to know 5 methods of string in c#
the easiest one
thanks in advance
: )
Posted 1-Oct-12 20:27pm
Updated 1-Oct-12 20:29pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
Try it yourself, you may find it is not as difficult as you think!
qureshiaquib 2-Oct-12 2:36am
thats not my homework
but i just want to know the easiest example of string. Just got clicked in mind.
And if i want to use this all in a same example? I just want to use all the five in a simple example? Can i do that?
OriginalGriff 2-Oct-12 2:50am
Probably - but if it isn't your homework why would you want to?
Normally, we have a task, and look for the methods that make it easiest and quickest to accomplish...
qureshiaquib 2-Oct-12 3:15am
hey bro. i just want to know. so i asked. all time their should not be a homework
gaining knowledge and nothing else. i found more and tried also
string s1 = "aquib";
string str3 = s1.ToUpper();
string str2 = str3.ToLower();
object clone1 = s1.Clone();
string str5 = s1.Replace('a','Y');
i told ya i am not a coder i am a learner.
and by the way some time some one will also asked this on google and google will redirect here. so this will help them too.
qureshiaquib 2-Oct-12 3:19am
bro about my regex question i found this one
which is much better but it takes
5421318421 means it takes only numbers also
how to avoid that. can you help me out
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Strange question´, but here are the five methods that I think are the easiest or most important ones:
string test = "Hello World";
string[] parts = test.Split(' ');   //splits the string into pieces
bool bIsEmpty = String.IsNullOrWhiteSpace(test);   //checks if the string is empty
int nWhiteSpace = test.IndexOf(' ');   //finds index of first whitespace in string
test = test.Replace(" ", ""); //removes any white space in string
test = test.ToUpper();  //transforms the string to uppercase
qureshiaquib 2-Oct-12 2:43am
thanks jf
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

It does not work like this here.

Here is what is expected of enquirers:
1. TRY first what you want to do! You may find that it's not that hard.
2. Formulate what was done by you that looks like an issue/not working.

Try them and tell if you face issues.
Members will be more than happy to help like this.

For now, you could have done MSDN and seen: String Methods[^]
- Concat
- Compare
- EndsWith
- Format
- StartsWith
- Subtring
- ToUpper
- ToLower

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170624.1 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100