|
You can Replace them with empty strings.
|
|
|
|
|
you can simply remove , and . from your string value by using Split function.
take a look how to display
string str = "abc, d.e f,g h,i. j,k";
string[] arr = str.Split(',', '.');
foreach (string str1 in arr)
{
Console.Write(str1);
}
modified on Monday, January 24, 2011 1:04 AM
|
|
|
|
|
That doesn't remove them, it just shows them.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
|
|
|
|
|
Henry Minute wrote: That doesn't remove them, it just shows them.
check my code again I have programmed it and then compile and after compilation it gives me output like "abc de fg hi jk".
now what will you say it is removing or showing
|
|
|
|
|
It has not removed them from the original string, they are still there.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
|
|
|
|
|
If it works for me as well as OP then how it isn't work for you. i have again try and it gives me same output
modified on Sunday, January 23, 2011 10:54 PM
|
|
|
|
|
One addition to your code
string str = "abc, d.e f,g h,i. j,k";
string[] arr = str.Split(',', '.');
foreach (string str1 in arr)
{
Console.Write(str1);
}
Console.Write(str);
What do you get when you run that?
The commas and stops are still there. So, once again I say, your code does not remove those characters as the OP asked.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
|
|
|
|
|
Henry Minute wrote: What do you get when you run that?
yes If I will use your program it will give me Original string but I did programming for removing character and then display it.
as i getting OP also what this that's why he greet me for my answer.
you are right in your point of view
|
|
|
|
|
RaviRanjankr wrote: he greet me for my answer
Yes, and that makes me question his abilities even more.
|
|
|
|
|
It may give the appearance of being correct but I don't believe it is what the OP asked for. You are not removing the characters from the string but simply creating an array that excludes them. Now you must recombine the array of characters back into a string to be able to use it.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
yes Mark as Henry pointed me I did big mistake I've not focused my mind on that. now I am realize it was my fault. because of my program OP can only display output after removing character. its not going to remove character from string.
its all happen in hurry
|
|
|
|
|
Thanks ravi it works for me.
|
|
|
|
|
you are always welcome
|
|
|
|
|
Although the method will produce the results it is inefficient and causes extra work for you. The String.Replace method is more suitable for the usage you have given.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You can do str = str.Split ( ... ).Join ( ... ) , but it's not the right tool and inefficient.
|
|
|
|
|
I have done Minor changes in my answer
string str = "abc, d.e f,g h,i. j,k";
string[] arr = str.Split(',', '.');
str = string.Empty;
foreach (string str1 in arr)
{
str += str1;
}
Console.WriteLine(str);
|
|
|
|
|
Simple form :
str.Replace("," , yourValue);
Alternatively you could construct some regex to do the job.
Cheers
If you can read this, you don't have Papyrus installed
|
|
|
|
|
My first answer is only able to display value after removing character it will not remove for permanent.
you can us Replace Method to remove . and ,
string str = "abc, d.e f,g h,i. J,k";
str = str.Replace(',',' ');
str = str.Replace('.', ' ');
Console.WriteLine(str);
|
|
|
|
|
Using the Regex class -
strComma = ",";
strReplace = string.Empty;
Regex Re = new Regex(strComma);
string newstring = Re.Replace(str,strComma,strReplace);
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
modified on Sunday, January 23, 2011 11:29 PM
|
|
|
|
|
Abhinav S wrote: string.Rmpty;
Now that is funny.
I must get a clever new signature for 2011.
|
|
|
|
|
string.Rmpty is perfectly acceptable syntax with the Scooby-Do extensions installed.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Is fixed now.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
|
|
|
|
|
Try this.
string str = "abc, d.e f,g h,i. J,k";
str = str.Replace(',', string.Empty).Replace('.', string.Empty);
|
|
|
|
|
I am trying to make a custom open file dialog. So far I managed that it works in VS's UserControl TestContainer. As to the next steps whatv I have to do, I am lost. I have tried to find help in MS docs an on Goolgle but obviously I don't know what to search for, because I found no usefull answers.
So, can someone briefly outline to me the steps which I should take - or better yet - point me to proper point where I can read about it (walkthrough or something like that)?
Regards
|
|
|
|
|
Well I figured a search for "custom open file dialog c#" would be a good start, which yielded this list[^].
I must get a clever new signature for 2011.
|
|
|
|