how can i write functions in String class without using any tools?
-
Is that not a built-in class or prepared method? Forgive me, but this does sound like a school assignment.
yes, our professor is wanted us to write a program like that and he told us that we can get help from everyone we want. and i'm getting help from you :).
-
how can i make my string to char[] without using any built-in classes or prepared methods, += and = or 'foreach' in C#? in an other expression, i want to (have to) write trim, insert, concat, countOf(char c) and etc without using any of methods or classes or foreach and even += or + in C#. how is that? please help, thanks.
I don't see how you can do it without =, but a string is an array of chars, and if you use a for loop instead of foreach, you can get each char by index, as in myString[0]
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
-
yes, our professor is wanted us to write a program like that and he told us that we can get help from everyone we want. and i'm getting help from you :).
You'll need to do some coding of your own, and then ask for specific help when you get stuck. You can't just come in here and ask for the code. that's not how it works. The forums aren't for you to get your solution done for you. And you'll find that in most of the forums available.
-
excuse me, but as i said, i haven't too use any prepared method for that.
If you cant use any methods on it, then the string is opaque to you, and there is no way you can do anything with it. I think you read your assignment wrong. Try again.
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008) -
how can i make my string to char[] without using any built-in classes or prepared methods, += and = or 'foreach' in C#? in an other expression, i want to (have to) write trim, insert, concat, countOf(char c) and etc without using any of methods or classes or foreach and even += or + in C#. how is that? please help, thanks.
Is there a reason why you are wanting to reinvent the wheel?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
how can i make my string to char[] without using any built-in classes or prepared methods, += and = or 'foreach' in C#? in an other expression, i want to (have to) write trim, insert, concat, countOf(char c) and etc without using any of methods or classes or foreach and even += or + in C#. how is that? please help, thanks.
Cute. Considering that String IS a class under .NET, that kind of makes the assignment contradictory to itself, now doesn't it?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
I don't see how you can do it without =, but a string is an array of chars, and if you use a for loop instead of foreach, you can get each char by index, as in myString[0]
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
excuse me, but i haven't to use indexes, too.
-
excuse me, but i haven't to use indexes, too.
Then I suspect your teacher is a moron. An index is the only way to get those chars out of the string.
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
-
Is there a reason why you are wanting to reinvent the wheel?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
no but it's my homework :) and i have to write that till next two days!
-
excuse me, but i haven't to use indexes, too.
So - are you meant to use telepathy? Your professor has effectively ruled out all useful constructs.
Deja View - the feeling that you've seen this post before.
-
Is there a reason why you are wanting to reinvent the wheel?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
Yeah, it's homework. I don't have a problem with trying to point him in the right direction, he was up front about it and he's not asking for a solution. It sounds messy tho.
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
-
Cute. Considering that String IS a class under .NET, that kind of makes the assignment contradictory to itself, now doesn't it?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008I think either the teacher is an idiot, or the OP is wrong in his understanding
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
-
no but it's my homework :) and i have to write that till next two days!
Sajjad Izadi wrote:
have to write that till next two days
Better get going then.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
Yeah, it's homework. I don't have a problem with trying to point him in the right direction, he was up front about it and he's not asking for a solution. It sounds messy tho.
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
Christian Graus wrote:
It sounds messy tho.
Gearing him up for real world maintenance projects, I suppose.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
I think either the teacher is an idiot, or the OP is wrong in his understanding
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
Christian Graus wrote:
the teacher is an idiot
Might be a safe bet. I don't even subject my CS students to worthless crap assignments. Assignments I push on them have some real meaning to them.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
Sajjad Izadi wrote:
have to write that till next two days
Better get going then.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
I think you need to re-read the assignment. You seem to be saying 'turn a string into a byte array without using any methods on the string class that would give you access to the contents of the string'.
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
-
Christian Graus wrote:
It sounds messy tho.
Gearing him up for real world maintenance projects, I suppose.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
*grin*
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
-
Christian Graus wrote:
the teacher is an idiot
Might be a safe bet. I don't even subject my CS students to worthless crap assignments. Assignments I push on them have some real meaning to them.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
Yeah, they should be learning things they can use, although I am always for students writing a list class that they will never use, for example.
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
-
I think you need to re-read the assignment. You seem to be saying 'turn a string into a byte array without using any methods on the string class that would give you access to the contents of the string'.
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
Didn't you mean to direct this to Sajjad? I'm not the one doing the assignment :-\
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
So - are you meant to use telepathy? Your professor has effectively ruled out all useful constructs.
Deja View - the feeling that you've seen this post before.
I usually suggest prayer when people ask stuff like this.
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.