|
A few others have replied here saying to use ArrayList. That is fine. If you're using .NET 2.0, you can use the System.Collections.Generic.List object to store your Person objects in a strongly-typed fashion (which ArrayList will not do). For example:
using System.Collections.Generic;
...
List< Person > persons = new List< Person >();
persons.Add(somePerson);
persons.Add(5);
-- modified at 10:39 Wednesday 8th March, 2006
|
|
|
|
|
Thanks Judah Himango ..
Your coding was very useful to me.
Thanks a lot
Thanks n Regards,
Ramya.R
|
|
|
|
|
hi
like console applications is run in the cmd prompt how i can run the classlibrary in the cmd prompt .Does any one know the command for it .
sasi
|
|
|
|
|
You can't, a class library is just that, a library, which contains lots of methods/classes but no interaction.
Either build yourself a simple console application to access and test the classes.
Or use something like NUnit to test your library.
|
|
|
|
|
Hello all,
I create one struct now i have to send this data to socket method SentTo . But SendTo method require byte[].
Now how can i convert struct type to byte[].
Thanx in advance.
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
You will have to write a custom method that does it. We may help you achieving this, if you post the code for your struct.
Also, do you have control of both communication endpoints?
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Hello Michel,
Check your mail. or click here[^].
Thanx for responcing.
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
Huh?
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
I send you the whole code on your email address.
Plz collect it from there.
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
Here's how.
public struct MyStruct
{
public int x;
public int y;
public float z;
}
IntPtr p;
MyStruct s;
int size;
byte[] buffer;
s = new MyStruct();
s.x = 1;
s.y = 2;
s.z = 3.0f;
size = sizeof( typeof( MyStruct ) );
p = Marshal.AllocHGlobal( size );
Marshal.PtrToStructure( s, p, true );
buffer = new byte[ size ];
Marshal.Copy( p, buffer, 0, size );
Marshal.FreeHGlobal( p );
I hope this helps.
Deus caritas est
|
|
|
|
|
Sorry, the Marshal.PtrToStructure should be Marshal.StructureToPtr .
Deus caritas est
|
|
|
|
|
Greate. Good.
I will help me throught out my project.
Thanx Andy.
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
I deal with packets to byte streams quite frequently in client/server applications. Packets are essentially data structures with an assortment of binary and ascii or whatever formatted data. Here are a couple functions you could use, and polymorhisize as you need:
<br />
public int Encode( int i32Value, ref byte[] pdu, int off )<br />
{<br />
byte[] byte32Int = new byte[ cBytesPerWord32 ];<br />
int netValue = System.Net.IPAddress.HostToNetworkOrder( i32Value );<br />
byte32Int = BitConverter.GetBytes( netValue );<br />
Array.Copy( byte32Int, 0, pdu, off, cBytesPerWord32 );<br />
return cBytesPerWord32;<br />
}<br />
<br />
public int Decode( ref byte[] pdu, int off, ref uint u32Value )<br />
{<br />
uint netValue = BitConverter.ToUInt32( pdu, off );<br />
u32Value = (uint)System.Net.IPAddress.NetworkToHostOrder( (int) netValue );<br />
return cBytesPerWord32;<br />
}<br />
Although the function above only deals with 32-bit uint's you can imagine how easy it is to add support for 16-bit and 64-bit integers/unsigned integers. Strings are variable length in most cases otherwise a simple Array.Copy() would suffice. So if you have to pass strings, at a minimum you'll be best served with a length byte and quite possible some sort of a type or tag byte - especialy if you have lots of string elements. That way you can handle strings in any order.
Good luck
Mike Luster
CTI/IVR/Telephony SME
|
|
|
|
|
HI,
Can anyone tell me how to access remote registry which is in different domain?...I am getting UnauthurizedAccessException
|
|
|
|
|
You would have to establish a trust between the local and remote domains or impersonate a user from the other domain.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
thanks for the reply........but can u say me how can i do that???....cos i am new to c#...thanks in advance
|
|
|
|
|
It is more an administration task than a programming one. One thing you could do, though, if you have access to the remote server and can install a web service on it, you could write a web service that gives access to the local registry.
Btw, why do you want to have access to the remote registry? Generally, it is not a good idea to open the registry to the outside world.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Actually my project is about retrieving softwares and hardware information from each system(from registry) in a lan...I used RegistryKey class to do that...for remote system,i used OpenRemoteBaseKey method...All works for me within a domain...If i do that for a system in another domain,then UnauthorizedAccessException is coming...Can u help me in this situation
|
|
|
|
|
You have 2 choices:
1- Make the 2 domains trust each other, and have an account that has admin privileges in both, if it is possible.
2- Run your program in each domains, separately.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
ok Michel.......very much thanks.......I will try the first one.....Do tell me if we have any other way...........
|
|
|
|
|
I want to disable some windows functions when my form loads. Would I just set the form to FixedDialog when you load it?
I want to disable the Alt-Tab function and the ctrl+alt+del functions so they cannot be used. How would you do this?
In the end we're all just the same
|
|
|
|
|
|
Actually all I want to do is disable the start button key on the keyboard... so you cant press it and bring up the start menu. What would making my main form afixed dialog do?
In the end we're all just the same
|
|
|
|
|
I have a context menu and I was wondering was there a way of getting it to look like the windows start menu. I want just to add a panel on the side of the menu which looks like the one in windows Start Menu eg the Windoiws 98 Start menu says Windows 98 down the side of it. This is what I want
In the end we're all just the same
|
|
|
|
|
how to display data in treeview from access database ,, and to add child to tree and database
|
|
|
|