Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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
Edited 1-Oct-12 20:29pm
JF201553.1K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Replace
Substring
EndsWith
StartsWith
Trim
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!
  Permalink  
Comments
qureshiaquib at 2-Oct-12 2:36am
   
thats not my homework
:laugh:
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 at 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 at 2-Oct-12 3:15am
   
hey bro. i just want to know. so i asked. all time their should not be a homework
:laugh:
gaining knowledge and nothing else. i found more and tried also
string s1 = "aquib";
string str3 = s1.ToUpper();
Console.WriteLine(str3);
string str2 = str3.ToLower();
Console.WriteLine(str2);
object clone1 = s1.Clone();
Console.WriteLine(clone1.ToString());
string str5 = s1.Replace('a','Y');
Console.WriteLine(str5);
Console.ReadKey();
}
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 at 2-Oct-12 3:19am
   
bro about my regex question i found this one
^(?:[a-zA-Z0-9](?:\.|_|-)?)+[a-zA-Z0-9]$
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
good
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
  Permalink  
Comments
qureshiaquib at 2-Oct-12 2:43am
   
thanks jf
Rate this: bad
good
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
  Permalink  

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

  Print Answers RSS
0 Maciej Los 600
1 OriginalGriff 580
2 CPallini 220
3 RyanDev 161
4 Sergey Alexandrovich Kryukov 125
0 OriginalGriff 5,784
1 Sergey Alexandrovich Kryukov 4,838
2 Peter Leow 3,009
3 Maciej Los 2,894
4 DamithSL 2,465


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2014
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