|
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
|
|
|
|
|
Why does it have to be "or"?? Why not "and"??
|
|
|
|
|
Without using the built in members of the String class, you can't access it's data.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I was just wondering whether or not you can with unsafe code... could be fun...
Howsabout this :
private unsafe static void
F
(
string S
,
out char[] A
)
{
int index = 0 ;
fixed ( char* s = S )
{
while ( s [ index ] != '\0' )
{
index++ ;
}
A = new char [ index ] ;
fixed ( char* a = A )
{
while ( index >= 0 )
{
a [ index ] = s [ index ] ;
index-- ;
}
}
}
return ;
}
Or lambda expressions?
modified on Monday, July 7, 2008 11:47 PM
|
|
|
|
|
It could be an exercise intended to show that it can't be done.
But probably it's poor communication.
|
|
|
|
|
Here are Left and Right Trim methods that don't access any methods of the String class, but I hope this isn't what the teacher is expecting.
private unsafe static void
LeftTrim
(
string Subject
,
System.Collections.Generic.HashSet<char> Chars
)
{
fixed ( char* subject = Subject )
{
int* length = (int*) subject - 1 ;
int front = 0 ;
int back = 0 ;
while
(
( front < *length )
&&
( Chars.Contains ( *(subject + front) ) )
)
{
front++ ;
}
while ( front < *length )
{
*(subject + back++) = *(subject + front++) ;
}
*length = back ;
}
return ;
}
private unsafe static void
RightTrim
(
string Subject
,
System.Collections.Generic.HashSet<char> Chars
)
{
fixed ( char* subject = Subject )
{
int* length = (int*) subject - 1 ;
while
(
( *length >= 0 )
&&
( Chars.Contains ( *(subject + *length - 1) ) )
)
{
(*length)-- ;
}
}
return ;
}
|
|
|
|
|
hi all ,
i have a datagrid nameddatagrid1 that is used to display no of rows
so now my requirement is like if i am selecting a particular row then all elements of that row should get displayed on the form
event happening like that...
on form load grid is loaded..
there is a menu like edit its clicked after selecting the row
all row elements are displayed to the a new form...
now can anybody help me here to geting the values to the text boxes..
example textBox1.Text=?
vikas da
|
|
|
|
|
You can access values of rows in the selected column by index, or if not all the data is shown, you should expect to store an id in the row which you can then grab to read data from the DB.
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.
|
|
|
|
|
Thanks alot for your reply ... i am not getting the syntax ..
like how to read the gridvalue
// some code to convert dataset [] val=datagrid1.rowsSlected
after getting above i can do like
textBox1.text=dataset[0];
....
.
.
.
.
i tried with hardcoded values like textbox1.text="5"
then onload the page is having the value in text field 1 ...
please help me here..
vikas da
|
|
|
|
|
dataset.Rows[0][0] if 0 is the selected row.
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 am trying to add an item to a list box from another class. I can add an item from within the same class with no problem, but when I try to add it from another class nothing happens even though when I folow it through it goes through all of the code. Can someone tell me how to resolve this problem (see below).
Thanks in advance,
Michael
Class1
{
buttonAddItem()
{
AddItem(); // Adding and item to my listbox works here.
}
public void AddItem()
{
this.ListBox.BeginUpdate();
this.ListBox.Items.Add(“AAA”);
this.logListBox.EndUpdate();
}
}
Class2
{
Class1 C1 = new Class1();
C1.AddItem(); // Adding from C2 to C1 does not work.
}
|
|
|
|
|
Looks to me like you need to do some reading on how OO works. Creating a new Class1, means exactly that. C1 has NOTHING to do with any other Class1 instance that is already running in your code. C1 will indeed add that item. But, it's not visible anywhere, so why would you see it ? A DIFFERENT Class1 instance continues to show the items that it has.
The correct way to deal with this is to set up delegates between the two classes. This needs to be done outside the constructor, obviously.
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.
|
|
|
|