|
lolla2006 wrote: i have a small project which is to create your own version of arralist in c# but of course without using the arraylist collection ...
That doesn't look like it should be an implementation of ArrayList at all, it looks like it should be an implementation of a linked list.
lolla2006 wrote: this is the initial scratch..please i need all help that you can offer me
how can i do this?
You write some code...
Is there anything specific that you have any problems with? Otherwise it's not really possible to give any specific advice.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
yes i have a problem with deleting a range of nodes from specific index to another
while(1)
System.out.println("I love Palestine ");
|
|
|
|
|
That's pretty basic:
1. Locate the node before the range and the node after the range (just loop and count).
2. Make the node after the range the next node for the node before the range, and make the node before the range the previous node for the node after the range.
You have to check for two special cases, though. If the first node in the range is the first in the list, there is no node before, and you have to change the first variable of the list instead. If the last node in the range is the last node, there is no node after, and you have to change the last variable of the list instead.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
i have finished every thing but i have three errors i dont know how to deal wiuth:
Error 1 'myArrayList1.Mylist.Contains(object)': not all code paths return a value
Error 3 Operator '>' cannot be applied to operands of type 'object' and 'object' <br />
how can i solve this
thnx 4 ur help
while(1)
System.out.println("I love Palestine ");
|
|
|
|
|
the code that makes the first error is :
public bool Contains(Object ValueToBeSerched)
{
Node WalkTheList = new Node();
WalkTheList = Root;
while (WalkTheList.getnextNode() != null)
{
if (WalkTheList.getvalue() == ValueToBeSerched)
return true;
else
WalkTheList = WalkTheList.getnextNode();
}
if (WalkTheList.getnextNode() == null)
return false;
}
the second error is the same but in this method :
public int IndexOf(Object ValueToGetIndex)
{
Node WalkTheList = new Node();
WalkTheList = Root;
while (WalkTheList.getnextNode() != null)
{
if (!WalkTheList.getvalue().Equals(ValueToGetIndex))
WalkTheList.getnextNode();
else
return WalkTheList.getIndex();
}
}
the code that generates the third error is this:
public void Sort()
{
Node WalkTheList = new Node();
Node Walker = new Node();
WalkTheList = Root;
Walker = Walker.getnextNode();
while (WalkTheList.getnextNode() != null)
{
if (WalkTheList.getvalue() > Walker.getvalue())
{
Object temp=null;
temp=WalkTheList.getvalue();
WalkTheList.setvalue(Walker.getvalue());
Walker.setvalue(temp);
}
WalkTheList = WalkTheList.getnextNode();
}
}
appratiate your help
while(1)
System.out.println("I love Palestine ");
|
|
|
|
|
1 & 2. Your first method is returning a bool, the second an int... but if you follow them through carefully you will see that it's possible for the end of your method to be reached without a return line being reached. This is one of the problems when you have more than one return point.
Better to create a variable of the return type at the start of your method initialized to a defualt value (false or 0 in this case) and set these instead then break out of any loops. Then as the last line of your methods return the variable.
3. GetValue obviously returns an object which doesn't support the > operator. Cast to a suitable type that does.
Dave
|
|
|
|
|
lolla2006 wrote: while(1)
System.out.println("I love Palestine ");
Oh dear - that looks so much like Java. What a shame.
Now, this doesn't look like an ArrayList, it looks like a Linked List - and probably a homework assignment. You should know that we never ever do your homework for you. If you have a specific question, then we may be able to offer some advice, otherwise you are on your own.
|
|
|
|
|
you know what??!!it is java i love java
thats right this is my own assignment i said that i have a problem with deleting from the list from a specific index to another...thats it
while(1)
System.out.println("I love Palestine ");
|
|
|
|
|
lolla2006 wrote: i said that i have a problem with deleting from the list from a specific index to another...thats it
Where? I looked in your original question and I can't find any references for it. However, what you need to do is set the next node of the item before your "index" to point to the item after the one you want to remove. You'll also want to set the previous node to refer to the .... well you get the idea.
|
|
|
|
|
i said that in my reply to Guffa ..anyway thanks for the idea
when im done with it im wondering could i give you the code to check it for me??
while(1)
System.out.println("I love Palestine ");
|
|
|
|
|
lolla2006 wrote: when im done with it im wondering could i give you the code to check it for me??
Well - you unit tests should help you with this. You won't need my help for this.
|
|
|
|
|
Hello guys. My name is Sachin. I have a small problem in my project which mostly hangs out my further works.
I have made a c# Windows Application from Visual Studio 2005.
I m posting the two demos of my main project..
Now
1 ) Demo
In this 'Demo' project.. I created few labels and few inherited UserControls. I put the numeric value in front of Basic Salary's usercontrol.. till then its fine.. But when i delete the values from usercontrol11 , some error is coming ...
I m unable to solve this... please help me..
Here is my Demo folder..
Download Demo.rar[^]
2 ) Demo1
In this 'Demo1' project.. Again I created few labels and now with textboxes. I put the numeric value in front of Basic Salary's textbox.. till then its fine.. But when i delete the values from textbox1 , same error is coming ...
If possible please try to help me..
Here is my Demo1 folder
Download Demo1.rar[^]
|
|
|
|
|
Please try for a more intelligent header.
nt_virus wrote: But when i delete the values from usercontrol11 , some error is coming
Try posting code and the error text, not expect people to download your project.
nt_virus wrote: But when i delete the values from textbox1 , same error is coming ...
Probably for the same reason. I would guess you have code that expects a number in there and blows up when there isn't one. Instead of int.Parse, use int.TryParse.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
nt_virus wrote: Hello. Small Help Needed.
Your title is a waste of time
nt_virus wrote: Hello guys. My name is Sachin
Thats nice, but is it really relevant?
nt_virus wrote: some error is coming ...
Do you think that telling us the error would help us in answering your question?
Plus, excuse my laziness, but I really cant be bothered downloading your project (which incidentally I have no way of verifing is legitimate) in order to help you out. The error message, plus some relevant code should more than suffice.
|
|
|
|
|
Hello.. The project is only of 30kbs each.. I m afraid.
Here is the screenshot of when I use usercontrol..
http://i34.tinypic.com/2z8b905.jpg
Code here..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Demo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void userControl11_TextChanged(object sender, EventArgs e)
{
label6.Text = userControl11.Text;
userControl12.Text = Convert.ToString(Convert.ToDouble(userControl11.Text) * .1);
userControl13.Text = Convert.ToString(Convert.ToDouble(userControl11.Text) * .01);
label6.Text = Convert.ToString(Convert.ToDouble(userControl12.Text)+Convert.ToDouble(userControl13.Text)+Convert.ToDouble(userControl11.Text));
}
private void userControl14_TextChanged(object sender, EventArgs e)
{
label6.Text = Convert.ToString(Convert.ToDouble(userControl12.Text) + Convert.ToDouble(userControl13.Text) + Convert.ToDouble(userControl11.Text)+Convert.ToDouble(userControl14.Text));
}
}
}
|
|
|
|
|
I've overriden the OnPaint routine in the GroupBox control to draw the border and text as to how I want it to be drawn.
But unfortunately, it also applies the *same* rendering to all the child controls that are placed within it.
The PaintEventArgs e doesn't have a property like Item or Control so I can't run a check to make sure that the child is an IGroupBox (which is the name of my custom control). So, how can I stop it from applying the render to all the children instead?
Thanks in advance.
|
|
|
|
|
u can use this two :
groupBox1.Contains(Control ctl) to see if the child is in the Group Box
or go to the child and ask him "who is your Parent" with
Control.Parent as ....
Have Fun
Never forget it
|
|
|
|
|
Unfortunately though, like I said, the PaintEventArgs e doesn't have any control properties. Only Graphics and ClipRectangle which means I don't know what's being painted.
How can I disable the OnPaint from rendering the child controls the same way? :\
|
|
|
|
|
Hi,
Does anyone know of a direct C# equivalent, or implementation, of java's System.identiyHashCode method?
Regards,
Dave
Regards,
Dave
|
|
|
|
|
maybe it is object.GetHashCode ???
|
|
|
|
|
That's "an" answer but I don't think it's "the" answer. The rason is that some objects override their base hashcode. And in this case it's the base hashcode that's needed. That's what the Java class returns, if I understand it corrctly.
Regards,
Dave
Regards,
Dave
|
|
|
|
|
did you try to cast that object to "object" and than use that code?
object wctohc = new WeirdClassThatOverridesHashCode();
wctohc.HashCode();
|
|
|
|
|
System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode( obj );
|
|
|
|
|
How Is it possible to turn off hyper threading?
|
|
|
|
|
In your BIOS.
From a coding point of view to run only on one logical CPU (aka hyperthread), you could probably set the processor affinity in the running process.
|
|
|
|