|
tamerana2004 wrote: I WANT THE IDEA ONLY NOT SOLVE THE CASE, IDEA OR WHAT HE WANT HEAR
It's very simple.
He want's exactly what the assignment says. It describes exactly what to do, and even how to do it. There is nothing that you have to figure out, you just have to type in the code.
What he does not want, however, is for you to try to make someone else do the assignment for you.
---
b { font-weight: normal; }
|
|
|
|
|
Go to rent a coder and pay 5 bucks
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
First try it yourself. If you really get stuck somewhere post the question here, explain what you've tried and where the problem lies. In that case people are more willing to help you.
|
|
|
|
|
When I test the String.Trim() function,my resource codes as follows:
using System;
using System.Collections.Generic;
using System.Text;
namespace Ch05Ex05
{
class Program
{
static void Main(string[] args)
{
string myString = " This is a test. ";
char[] separator = {' '};
char[] test ={ 'T', 'i' };
string[] myWords;
myString = myString.Trim(test);
// myWords = myString.Split(separator);
foreach (char C in myString)
{
Console.WriteLine("{0}", C);
}
Console.ReadKey();
}
}
}
The alphabet T and i should be removed ,but when I excuted my codes,It change nothing! Can you tell me why?
|
|
|
|
|
Trim removes occurrences only at the begin or at the end of the string (MSDN):
String.Trim (Char[])
Removes all occurrences of a set of characters specified in an array from
the beginning and end of this instance.
|
|
|
|
|
I have got it,Thank you! I'm a new learner on C#.I come from china.Would you mind to make friends with me? I would like that you can help to improve my english and my C#.And if you want to make a journey to china,I can be you guide. MSN:wanlim0817@hotmail.com
email:wanlim0817@yahoo.com.cn
|
|
|
|
|
I wiil be happy to be your friend. On the other hand, since I'm Italian, English is not my native language. Moreover I'm not that C# expertise (C++ is my native programming language...). Anyway I will happy to receive your questions...
|
|
|
|
|
I think you're looking for .Replace. You can replace T with an empty string.
Christian Graus - C++ MVP
|
|
|
|
|
I have got it,Thank you! I'm a new learner on C#.I come from china.Would you mind to make friends with me? I would like that you can help to improve my english and my C#.And if you want to make a journey to china,I can be you guide. MSN:wanlim0817@hotmail.com
email:wanlim0817@yahoo.com.cn
|
|
|
|
|
you can use string builder or you can use the replace function it will repalce the letter T with an empt space
venu gopal
|
|
|
|
|
|
"exit while;"
Ooops -VB.Net only...Last modified: 4mins after originally posted -- correction
|
|
|
|
|
I could certainly be missing something but I thought this was for VB not C#.
only two letters away from being an asset
|
|
|
|
|
There's an exit keyword in C#?
|
|
|
|
|
It's from C# language specification:
When multiple switch, while, do, for, or foreach statements are nested within each other, a break statement applies only to the innermost statement. To transfer control across multiple nesting levels, a goto statement (§8.9.3) must be used.
using System;
class Test
{
static void Main(string[] args) {
string[,] table = {
{"Red", "Blue", "Green"},
{"Monday", "Wednesday", "Friday"}
};
foreach (string str in args) {
int row, colm;
for (row = 0; row <= 1; ++row)
for (colm = 0; colm <= 2; ++colm)
if (str == table[row,colm])
goto done;
Console.WriteLine("{0} not found", str);
continue;
done:
Console.WriteLine("Found {0} at [{1}][{2}]", str, row, colm);
}
}
}
|
|
|
|
|
Ahhhh! Not the notorious goto!
|
|
|
|
|
Well, I don't much like goto myself but that's the way Microsoft specifications provide. The good thing is that at least all finally blocks are still processed so not much harm is done. Sometimes goto is far more comprehensive than additional boolean flags and checks in nested loops.
|
|
|
|
|
It's not notorious when used to branch to the end of a block. In fact, that's what break and return do.
Djikstra's paper has to do with branching into a control block, there making program verification orders of magnitude more difficult.
/ravi
|
|
|
|
|
Richard Hartness wrote: ase statements are terminated with the C# keyword break. Unde
I guess you could have a boolean flag as part of the while loop, bool isBreakingFromDefault, and just set that flag to true when you break from default. When the while loop sees that flag as true, break from the while loop as well.
FWIW, I think the switch construct is butt ugly and often confusing. I'd much rather see a few if/elses.
|
|
|
|
|
Judah Himango wrote:
FWIW, I think the switch construct is butt ugly and often confusing. I'd much rather see a few if/elses.
Wow - I think the reverse. They are, of course, the same thing in the end.
Christian Graus - C++ MVP
|
|
|
|
|
Judah Himango wrote: I think the switch construct is butt ugly and often confusing. I'd much rather see a few if/elses.
the switch is excellent, but not really usable in every case, but so are if/elses. Just use the right tool for the job .
|
|
|
|
|
Even though you already mentioned this, it's short, and pretty much the standard:
bool bContinue = true;
while( myOtherCriteria && bContinue)
{
case...
...
...
otherwise:
bContinue = false;
}
|
|
|
|
|
To be weirder, you can throw an exception...
|
|
|
|
|
Richard Hartness wrote: C# seems to break down a little.
Actually, I don't think this has anything to do with C# per se. C and C++ work the same way.
/ravi
|
|
|
|
|