|
Hi Everybody,
I wrote a class like this
public class Node
{
private int data;
private string key;
#region Constructors
public Node(string key, int data)
{
this.key = key;
this.data = data;
}
#endregion
#region Public Properties
public int Value
{
get
{
return data;
}
set
{
data = value;
}
}
public string Key
{
get
{
return key;
}
set
{
key = value;
}
}
#endregion
}
public class test
{
public static void Main()
{
ArrayList a = new ArrayList();
Node n = new Node("ab", 1);
a.Add(n);
PrintValues(a);
}
public static void PrintValues( IEnumerable myList )
{
System.Collections.IEnumerator myEnumerator = myList.GetEnumerator();
while ( myEnumerator.MoveNext() )
Console.Write( "\t{0}", myEnumerator.Current.ToString());
Console.WriteLine();
}
}
My problem is How do I get and set values for each node in this Array List and How do I print out to the screen.
Thanks for your help and time.
Raj
|
|
|
|
|
You have to cast the elements of your ArrayList.
<br />
public static void PrintValues( IEnumerable myList ) <br />
{<br />
System.Collections.IEnumerator myEnumerator = myList.GetEnumerator();<br />
while ( myEnumerator.MoveNext() )<br />
{<br />
Console.Write( "\t{0}", ((Node) myEnumerator.Current).Key.ToString());<br />
Console.WriteLine();<br />
}<br />
}
|
|
|
|
|
Please take a good look at this and give me some clues!!!
I need to list every table in the Access database.
This code (which is from the .NET Framework Class Library DataTableCollection Class page on MSDN) appears to get the info that is needed, but what does the dataset coding look like for this to work?
private void GetTables(DataSet ds) <br />
{ <br />
foreach (DataTable t in ds.Tables) <br />
foreach (DataRow r in t.Rows) <br />
foreach (DataColumn c in t.Columns) <br />
if (r[c] != null) <br />
Console.WriteLine(r[c]); <br />
}
Regards,
Bill Antonacchio
|
|
|
|
|
Hi Bill. You're going to want to use the GetOleDbSchemaTable method of the OleDbConnection object to get your list of tables. This Microsoft KB document should help.
http://support.microsoft.com/?id=309488[^]
|
|
|
|
|
|
Thanks Mike I will give that a try.
Regards,
Bill Antonacchio
|
|
|
|
|
Yes, I know about the registry, but I need to read an ini file.
Could you point me towards the C# counter part of
GetPrivateProfileString.
thanks
|
|
|
|
|
http://www.codeproject.com/csharp/ReadWriteXmlIni.asp
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
There's already a class in the Files And directories category, and I have published another today, so if it does't get available, send me an email!
kratchkov@inbox.lv
|
|
|
|
|
|
I want to create a toolbar that is very narrow and vertical. In the design mode this is very easy. BorderStyle=None. Dock = DockStyle.Left.
That said, the dialog box expands 3 fold in runtime mode.
Any suggestions on how to create a very narrow / verticle toolbar?
thanks
|
|
|
|
|
Try setting the maximum, and minimum sizes of the application to the same size to restrict it from changing.
this.MinimumSize = new Size(40, 400);
this.MaximumSize = new Size(40, 400)
It shouldn't be expanding on its own like that, unless there is something that is causing it to do so. By setting the min/max sizes, it will remain the same size no matter.
|
|
|
|
|
Does someone know how to eject and/or close cdrom trays in C#?
|
|
|
|
|
Download this nice application http://www.brightweb.co.uk/CDROMManager.zip
|
|
|
|
|
Try this:
using System.Runtime.InteropServices;
[DllImport("winmm.dll", EntryPoint="mciSendString")]
public static extern int mciSendStringA(string lpstrCommand, string lpstrReturnString, long uReturnLength, long hwndCallback);
mciSendStringA("Set CDAudio Door Open Wait", null, 0, 0);
to close it I believe its "Set CDAudio Door Close Wait", null, 0, 0);
I can't test it on my system because mine doesn't have autoclose i have to manually close it.
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
hai there,
i have a query to ask you(related remoting concept). See i have a class in my server machine and this class is reused by the client machine. After accessing the facilities of server class my client machine will release the server object.
My question is how can i keep track of total how many times my server class is used by other clients.
how can i impliment this counter concept.
Note : concept is same as no of times a perticular webpage is visited.
but here my application is windows application.
hai, feel free to contact
Sreejith SS Nair
|
|
|
|
|
In your class define a static field (static int instanceCount = 0), and then in the constructor increment this with instanceCount++
And decrement in the destructor.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
It depends on the activation type. If you use a client-activated single call remoting object, then you'll need to use a static field like the first reply mentioned. If you're using a singleton, then since each client gets the same instance, you can use a simple instance field.
In either case, if you want to persist this, consider either logging each time a client connects to a file or database along with some basic information about the client, much as a web or FTP server would do. It's more robust and if the machine fails, you won't have to worry about your counter being reset. Another possibility is to use performance counters (see System.Diagnostics.PerformanceCounter ) which can be persisted by setting up a performance monitor and logging it with the perf counter you would create. This is even more robust since you don't actually need to write a log parser.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Here i use BitBlt(destDC,x,y,w,h,srcDC,x,y,SRCCOPY) to copy srcDC into
destDC.
i think GetPixel(destDC,x,y) can get the Pixel info at Point(x,y).
and my question is :
can i get bytes info from destDC directly ?
because i think get bytes directly is faster than GetPixel()'s way.
why do i bring out this question?
i have read a msdn help 'How to save a true color bitmap into a Gif file'
which tells me how to get the pixelinfo and save the bitmap into a gif
file.And the help says while doing pixels processing,the LockBits() method
is more efficient than GetPixel()'s way.
so i think whether there is a way to get bytes info from DC directly like
LockBits() do.
|
|
|
|
|
Yes, use lockbits. If you're using C#, unless you're loading the old GDI functions directly and calling them, you can do it exactly as they describe, and as I show in my image processing articles. If you've got a HDC, and not a Bitmap, you can create a Bitmap from a HDC, otherwise you'll need for the image to be a DIBSection, in which case you'd have a pointer to the image data already.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
oh,thanks for ur suggestion.
and where can i find ur "image processing articles"?
while i m looking for DIBSection on MSDN,i dont know the
corresponding types in C# to types in C such as LPVOID ,and so on.
|
|
|
|
|
fu0 wrote:
and where can i find ur "image processing articles"?
I don't know what 'ur' means, but my image processing articles are here on the code project site.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hello:
Is there a way to set application properties that are global and accessible from all points in the program. I have tried public static classes, constants, properties on the main form, properties in the app object, but it always tells me that the "prop" is not in scope.
How do you guys handle this kind of problem for setting application wide defaults. It was easy in vfp, but i'm pulling my hair out here (what's left of it anyway).
Thanks.
|
|
|
|
|
Having one class with static fields is good. Just make shure that all class'es are in the same namespace.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
The classes are in different namespaces. I thought adding a reference to the individual namespaces would allow me access to the class from anywhere. Is that not true?
|
|
|
|