|
Is this a school assignment?
|
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
|
So - are you meant to use telepathy? Your professor has effectively ruled out all useful constructs.
|
|
|
|
|
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.
|
|
|
|
|
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!
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
Oh, I hate it when people do that...
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.
|
|
|
|
|
Oh well, no worries
"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.
|
|
|
|
|
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
|
|
|
|
|
*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.
|
|
|
|
|
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I'll admit I have some code that is a maintenance nightmare, considered "job security" to a certain extent
"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
|
|
|
|
|
Cute. Considering that String IS a class under .NET, that kind of makes the assignment contradictory to itself, now doesn't it?
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
Christian Graus wrote: always for students writing a list class that they will never use
Sure, it primes them up for writing code that never gets used because boss says otherwise, and writing something like a list class teaches the fundamentals of OOP.
Christian Graus wrote: they should be learning things they can use
Exactly, since they will walk out of the classroom with, hopefully sharper skillsets that can be of value to them. I've had students in the past, who earned lower than average grades thank me for increasing their skillsets, though their academic grade doesn't necessarily reflect it.
"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
|
|
|
|