|
Hi,
I've been looking over the Collection classes available through the .NET framework and it seems that LinkedList hasn't been provided (Unless it is in some other namespace which I haven't checked - If so could you point it out - Thanks!).
Any ideas as to why they haven't included it in the Framework? It is a very useful data structure and has many uses just as ArrayList does.
Actually... it would be a good article to compare the Collections framework that .NET and Java provide. Cause I know that the Java Collections framework is heavily based on inheritance and abstract classes. It would be an interesting article to see the differences between them.
As a side question - Are the .NET Enumerators the same as the Java Iterators?
Thanks very much.
Mohnish
|
|
|
|
|
mohn3310 wrote:
Any ideas as to why they haven't included it in the Framework?
Good question, it does seem odd that it isn't there. You could easily create your own version of it though. If you don't know how to create a linked list there are many places on the web that will give you code for doing it
mohn3310 wrote:
Are the .NET Enumerators the same as the Java Iterators?
Enumerators in .NET are used to go through a collection an element at a time.
IEnumerator ie = myCollection.GetEnumerator();
while(ie.MoveNext) {
System.Console.WriteLine("object: " + ie.Current.ToString());
} or if you are using C# you can use foreach
foreach(object foo in myCollection) {
System.Console.WriteLine("object: " + foo.ToString();
} Simple, eh?
HTH,
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Thanks James!
Yes, LinkedLists are relatively simple to create and there are lots of examples on the web, but I was just wondering why they didn't include it since it's such a generic data structure.
Normally we would create wrappers to ArrayLists or LinkedLists to make them typesafe (using our own classes) rather than using Objects.
Yeah, enumerators do seem to act like iterators in java.
Cool... thnx again
Mohnish
|
|
|
|
|
mohn3310 wrote:
Normally we would create wrappers to ArrayLists or LinkedLists to make them typesafe (using our own classes) rather than using Objects.
Microsoft has made that part easier on us developers
Collection Generator for .NET 1.0 creates a collection based on ArrayLists to store objects of a specified type.
Until .NET supports generics this is the best solution to it.
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
I learned in some articles here describing using DHTML new feature in MFC7.
Will it be possible to use such a control in windows forms (not web form)? I hope it will ease the maintainment of the user interface, and maybe provide a way that user can custom his favourite dialog.
and another question is there in any corner of visual studio .net that two columns list control which studio used to edit properties provided? does microsoft kind enough to provide us a such powerful control? I wanna use it to set some object's properties in my form.
|
|
|
|
|
Chen, Fu wrote:
Will it be possible to use such a control in windows forms (not web form)?
You'll have to look at using hosting the web browser control on your form to use anything with DHTML. I'm not sure if it supports DHTML by default or if you have to do some coding to add that functionality.
Chen, Fu wrote:
and another question is there in any corner of visual studio .net that two columns list control which studio used to edit properties provided? does microsoft kind enough to provide us a such powerful control? I wanna use it to set some object's properties in my form.
Look for the PropertyGrid, right click on the toolbox and choose "customize toolbox" then goto the .NET Framework Controls tab, you should find the PropertyGrid there.
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
yeah, i find the PropertyGrid now! it's very helpful to change the control's property at runtime.
Thanks!
|
|
|
|
|
C#'s compiled result is a exe in CLR code.
it said required JIT run.
does it mean compile to native code once software is deployed?
or compile each time we used it?
will it be a burden when we develop a fairly big application?
|
|
|
|
|
The JIT compiles each method as it is executed for the first time while running. This is why startup time for a .NET program is so long. You can get rid of the JIT by performing an install time JIT, ngen <assembly> will pre-JIT the code.
There is no guarantee the code won't be JITted again later. However I think it is a safe bet that won't happen since a reason to JIT is when the underlying IL has changed or it has been requested (usually for the above reason).
HTH,
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Thank you, very helpful.
well, I find it now -- ngen!
|
|
|
|
|
Hi,
If we use Properties in our Class we would need one "local" variable to actually hold the value and one to actually be accessed from the outside...
private string name; // local
public string Name // access outside
{
get
{
return name;
}
set
{
name = value;
}
}
So basically my question is... are there TWO variables or only ONE... Is the public one just for asthetic reasons? If there are two it would be wasting space everytime we use a Property wouldn't it?
Also the "value" parameter - is that always assumed in Properties, cause I don't see any explicit mention of it anywhere?
Thanks.
Mohnish
|
|
|
|
|
I think ONE. ( may be this approach can help us)
As we know , this the way of accessing member variables( state of the class) through methods(get,set) without breaking the client code.
Often memeber variables (State) need to be computed.(ex: get and set to/from DB),then this way of accessing will be useful.
I think this the trade-off.(If we really wasting space)
Check your MSIL using ILDASM.exe( NET FWk/SDK/ bin).
in your example, NAME is property and name is member variable.
Next,
value is implicit parameter for "set" method
CLR reads your program as
set(value)
{
membervariable = value;
}
Thanks,
Anand.
|
|
|
|
|
In your example there is only ONE real member variable: name. Indeed, "Name" just exists just for aesthetic reasons.
Your example doesn't yet show the advantages of using Properties. These arise if you add e.g. bounds-checking code to your get and/or set accessors.
Sito Dekker
|
|
|
|
|
I was wondering if someone can give me a sample code for Upload/Download on FTP.
Is it possible using only TcpClient,NetworkStream,StreamReader or I have to use Socket absolutely ?
Thanks for your help
|
|
|
|
|
I found a sample code here:
http://home.wi.rr.com/skulkarni/FTP/FTPIndex.html
rgrds
Martin
|
|
|
|
|
When a cell inside a datagrid has the focus and the up or down arrow key is pressed the focus moves to the previous or next cell. How can I intercept this event and execute code based on the pressing of the up or down arrow key? The OnKeyUp, OnKeyPress and OnKeyDown are not working as normal in the datagrid. Thanks for your help.
Kyle
|
|
|
|
|
kyledunn wrote:
How can I intercept this event and execute code based on the pressing of the up or down arrow key? The OnKeyUp, OnKeyPress and OnKeyDown are not working as normal in the datagrid.
You need to override the IsInputKey method to tell the datagrid that those keys are to be sent to OnKey* rather than treated specially by the underlying code.
You can only do this if you are creating a class that inherits from DataGrid though.
HTH,
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Thanks James,
What you say about this only being possible if you are creating a class that inherits from DataGrid makes sense since the IsInputKey is a Protected method. Do you know of any code examples available that would help me build this class and add the custom datagrid control to a windows form?
Kyle
|
|
|
|
|
The simplest thing to do is just override the methods that you need to.
public class myArrowKeyDataGrid : DataGrid {
public myArrowKeyDataGrid() : base() { }
protected override bool IsInputKey(Keys key) {
if( key == Keys.Left || key == Keys.Up || key == Keys.Down || key == Keys.Right ) {
return true;
}
else {
return base.IsInputKey(key);
}
}
protected override void OnKeyDown(KeyEventArgs e) {
Keys key = e.KeyData;
if( e.Handled == false && (key == Keys.Left || key == Keys.Up || key == Keys.Down || key == Keys.Right ) ) {
e.Handled = true;
}
base.OnKeyDown(e);
}
} Untested code of course, but thats the premise behind it all
HTH,
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Thanks James! Everything you wrote made perfect sense and should work. But I still can't get it to work, at least not completely. My data contains 5 text fields and a checkbox. It does work for the cell that has the checkbox but the cells that have the textbox never fire for either the IsInputKey and OnKeyDown events. How it's working for one data type and not another is a mystery to me. If you can think of anything I would appreciate hearing from you. It was very kind of you to help. Thanks.
Kyle
|
|
|
|
|
It'll make it so the Key* events won't fire when an arrow key is pressed but try moving the base.OnKeyDown call so its only called if the key wasn't an arrow key.
It could also be that the TextBox inside the cell is trapping those keys; so you're seeing the behavior of the TextBox and not the datagrid.
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
I know this is dumb question,but I am beginner in C# and do not have any book about it.
I have a text box and a button,when user press this button I want to check if the text boxes are
filled or not,and if the text is empty,change the text of button,I use this but it does not work:
private void Button1_Click(object sender, System.EventArgs e)
{
if(TextBox1.Text==null)
Button1.Text="Hello";
}
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
try this one:
private void Button1_Click(object sender, System.EventArgs e)
{
if(TextBox1.Text.Length == 0)
Button1.Text = "Hello";
}
or set the Enabled-Property of the Button to false at startup
and override the TextChange Property of your TextBox maybe like this:
private void TextBox1_TextChanged(object sender, System.EventArgs e)
{
if(this.TextBox1.Text.Length > 0)
{
this.Button1.Text = "Click me";
this.Button1.Enabled = true;
}
else
{
this.Button1.Text = "Hello";
this.Button1.Enabled = false;
}
}
rgrds
Martin
|
|
|
|
|
Thanx,I check it now
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
I think I made amistake about the place of my question,it's in a web form.My button does not enable when I add some text to text box???
Is there any difference between windows form and web application in this case?
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|