|
OriginalGriff wrote: DriveInfo is a class which I invented
System.IO.DriveInfo
|
|
|
|
|
Yes, yes, I know!
Just using it as a sensible name for a class the OP might want to implement to go with the "drives" array they already had.
I dunno, .NET has taken too many of the good names already, why can't they have used DICFMSTOMYLH instead, and left all the good ones to us? They used to in the early days!
DriveInfoClassFromMicroSoftTOMakeYourLifeHarder, in case you were wondering...You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
OriginalGriff wrote: DriveInfoClassFromMicroSoftTOMakeYourLifeHarder, in case you were wondering...
ROFL!
I was wondering, I knew there had to be some method to that madness var question = (_2b || !(_2b));
|
|
|
|
|
hi,
i have a char array in which i m getting path of current module.i want to convert it into string before loading it.hw can i do that?
|
|
|
|
|
Just use the constructor of string which accepts char array - here[^].
Example:
char [] charArr = {'A','B','C','D'};
string strFromCharArr = new string (charArr);
Regards
|
|
|
|
|
char[] charArray = new char[22];
string str = new string(charArray);
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Richard MacCutchan wrote: txtspeak is the realm of 9 year old children, not developers. Christian Graus
!
|
|
|
|
|
Can some body suggest me a sample where i can retrieve all my GMail Contacts and Add some contacts to Gmail... Please help me with a good sample in C#
|
|
|
|
|
|
Hi all.
I want to connect to a remote SQL Server with visual C# and get data from that to read and update. I use SqlConnection object but I dont know how to do it.
Can someone of U help me?
Such as : Tutorial or code if it is possible
thanks in advance.
|
|
|
|
|
I recommend buying a book and/or taking a class.
|
|
|
|
|
|
I'm developing a plug-in system. Each plug-in can register to handle a packet. I'd like to have the manager have some sort of "generic event", so the plug-in would look something like this:
public class TestPlugin : Plugin
{
public override void Register(PluginManager manager)
{
manager.OnPacket<Packets.SomePacket> += new PacketEventHandler(manager_OnPacketSomePacket);
}
public void manager_OnPacketSomePacket(PluginManager manager, PacketEventArgs e)
{
}
}
I could do it several other ways, of course, but the reason i'm looking for something like this is because if it's an event Visual Studio can generate a method stub, which is a useful functionality, which i'd definitely appreciate when i'm actually coding plug-ins.
I can't make a separate event for each packet because there are ~300 different kinds of packets that could be received.
Is there a way to do this, or an alternative that would keep the method-stub functionality I love so much?
Thanks in advance.
|
|
|
|
|
|
If there's a way to do it I haven't found the syntax.
|
|
|
|
|
My assumption is that the answer for this is that you cannot have a generic event for the same reason you cannot have a generic field in a non-generic class (or of a generic type that is not a type parameter for the class containing the field). If this was allowed, your class would have to vary in size depending on how many different events were used by external code, which of course is not allowed.
The best option that comes to mind is making all of the packet classes can inherit from some base packet class. Then you can make the event use that base class and have the handlers only process packets of the expected type.
|
|
|
|
|
That's disappointing.
Packets is actually an enum of type-codes for each packet. Then the plug-ins parse the data (which is fed through a PacketEventArgs class) based on the type code.
It seems about the only option would be to have a giant switch statement of packets, or a manager.Register(Packets.SomePacket, MyHandler) function.
I think i'll end up going the latter route, a gigantic switch statement just doesn't appeal to me.
Thanks for your help.
|
|
|
|
|
I had assumed you had a set of classes since generics would not accept an enum value as the type parameter (since it is a constant and not a type). You could still take the approach of letting the handlers receive all events and only process the ones they care about. Something like:
void PacketProcessor(object sender, PacketEventArgs e)
{
if (e.PacketType != Packets.SomePacket) return;
}
This has the advantage of making it obvious to the later reader of the code which packet is being handled by this function, but has the disadvantage all packet handlers will get called for all packets.
|
|
|
|
|
Hello, As you may see below, I'm trying to replace the contents of two tables with eachother from a Windows form but it doesn't work. It may not be the best practice I know and waiting for your valuable comments
SqlConnection conn = new SqlConnection();
SqlDataAdapter sqlAdaptorSource;
SqlDataAdapter sqlAdaptorTarget;
SqlCommandBuilder sqlCommandSource;
SqlCommandBuilder sqlCommandTarget;
DataTable dtSource = new DataTable();
DataTable dtTarget = new DataTable();
DataTable dtBackup = new DataTable();
public void changeTables()
{
conn.ConnectionString = @"Data Source=" + System.Environment.MachineName + @"\SQLEXPRESS;Initial Catalog=Kafe;Integrated Security=SSPI;";
conn.Open();
sqlAdaptorSource = new SqlDataAdapter("Select * From Table1", conn);
sqlAdaptorTarget = new SqlDataAdapter("Select * From Table2", conn);
sqlCommandSource = new SqlCommandBuilder(sqlAdaptorSource);
sqlCommandTarget = new SqlCommandBuilder(sqlAdaptorTarget);
sqlAdaptorSource.Fill(dtSource);
sqlAdaptorTarget.Fill(dtTarget);
dtBackup = dtTarget;
dtTarget = dtSource;
sqlAdaptorTarget.Update(dtTarget);
dtSource = dtTarget;
sqlAdaptorSource.Update(dtSource);
dtSource.Clear();
dtTarget.Clear();
dtBackup.Clear();
dtSource.Dispose();
dtTarget.Dispose();
dtBackup.Dispose();
conn.Close();
conn.Dispose();
}
|
|
|
|
|
teknolog123 wrote: it doesn't work
does not qualify as an accurate symptom description.
Are you aware a DataTable has a TableName property? and you haven't changed a thing inside such DataTables?
so all the data stays with the table name, no matter in what order you perform your Update()s.
|
|
|
|
|
thanks for your comment, would please show me a way of replacing the tables' contents? And how TableName property can help me?
|
|
|
|
|
Hy,
There's some wierd stuff in here:
dtBackup = dtTarget;
dtTarget = dtSource;
sqlAdaptorTarget.Update(dtTarget);
dtSource = dtTarget;
sqlAdaptorSource.Update(dtSource);
First you make the dtBackup refernce the dtTarget.
Then you the dtTarget reference the dtSource => the backup also points to dtTarget wich in
turn points to source.
Then you update the dtTarget, but the target points to source => so you update the source.
All of them point to the same thing
Remeber objects are passed default by reference.
What you want to do works fine for value types such as ints:
tmp = second;
second = first;
first = tmp;
|
|
|
|
|
thanks, would please show me a way of replacing the tables' contents?
|
|
|
|
|
use the Clone() method as in:
DataTable bckup = dt.Clone();
|
|
|
|
|