|
E_Gold wrote: Is anyone know some good Web sit's ?
Yes
Check here[^]
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Search on google I know to do....
I was asking for someone who work whit good website for tips & tricks
and whant to shere whit me
|
|
|
|
|
StackOverflow[^] has dedicated a page to some of the less-known features of the language.
Enjoy
I are troll
|
|
|
|
|
Hi,
I am having trouble using interfaces with a Generic List. I have taken an extract of my problem below which consists of two interfaces, one for a single object (itemInterface) and one for a collection of those objects (collectionInterface) and then the objects that implement these interfaces. Client and ClientCollection.
public interface CollectionInterface
{
bool IsServer
{
get;
set;
}
void LoadServerInserts(DateTime lastSync);
void LoadClientInserts();
void LoadServerUpdates(DateTime lastSync);
void LoadClientUpdates();
void LoadClientDeletes();
void LoadServerDeletes();
void RunCommand(string sql, bool isServer);
}
public interface ItemInterface
{
bool IsServer
{
get;
set;
}
bool IsNew
{
get;
set;
}
void Save(bool includeSyncBit);
void ClearSync();
}
Client : ItemInterface
{
//client related stuff inlcuding interface methods and members
}
ClientCollection : System.Collections.Generic.List<Client>, CollectionInterface
{
//client collection related stuff inlcuding interface methods and members
}
When I try and use these objects on a form I get the error:
foreach statement cannot operate on variables of type 'CollectionInterface' because 'CollectionInterface' does not contain a public definition for 'GetEnumerator'
This is on my windows form....
private void doSomething CollectionInterface a, CollectionInterface b, CollectionInterface conflicts)
{
//update the server with the client updates
foreach (ItemInterface item in a)
{
if ( b.Contains(row))
{
conflicts.Add(row);
}
}
}
I wondered if I needed to change the collection interface as follows:
public interface CollectionInterface:IList<ItemInterface>
But this gave me even more errors.
I would be really really grateful for any help on this, I have been tearing my hair out over the last few hours
|
|
|
|
|
Not sure why you need to do this. Making the ClientCollection class derive from List<Client> or List<ItemInterface> should be sufficient. Creating a n interface that derives from IList<ItemInterface> is just going to create a wrapper around an internal list of the same.
Anyway, this is how you do it. I've use IItem and ICollection for the interface names.
Client clientA = new Client(1);
Client clientB = new Client(2);
Client clientC = new Client(3);
ClientCollection clients = new ClientCollection();
clients.Add(clientA);
clients.Add(clientB);
clients.Add(clientC);
foreach(IItem item in clients)
{
Console.WriteLine(item.ID);
}
public interface IItem
{
Int32 ID { get; set; }
}
public interface ICollection : IList<IItem>
{ }
public class Client : IItem
{
public Client(Int32 id)
{
ID = id;
}
#region IItem Members
public int ID
{
get;
set;
}
#endregion
}
public class ClientCollection : ICollection
{
private List<IItem> list;
public ClientCollection()
{
list = new List<IItem>();
}
#region IList<IItem> Members
public int IndexOf(IItem item)
{
return list.IndexOf(item);
}
public void Insert(int index, IItem item)
{
list.Insert(index, item);
}
public void RemoveAt(int index)
{
list.RemoveAt(index);
}
public IItem this[int index]
{
get { return list[index]; }
set { list[index] = value; }
}
#endregion
#region ICollection<IItem> Members
public void Add(IItem item)
{
list.Add(item);
}
public void Clear()
{
list.Clear();
}
public bool Contains(IItem item)
{
return list.Contains(item);
}
public void CopyTo(IItem[] array, int arrayIndex)
{
list.CopyTo(array, arrayIndex);
}
public int Count
{
get { return list.Count; }
}
public bool IsReadOnly
{
get { return false; }
}
public bool Remove(IItem item)
{
return list.Remove(item);
}
#endregion
#region IEnumerable<IItem> Members
public IEnumerator<IItem> GetEnumerator()
{
return list.GetEnumerator();
}
#endregion
#region IEnumerable Members
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
#endregion
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hello,
Can someone help me understand how to read a packet?
I believe i have gathered all the necessary bytes but am having a hard time reading the data from the packet.
I thought I could attach the pdf here, but instead i will provide a snippet and maybe i can move on from there.
Here are the first 10 bytes as described in the document I have.
Unique Header Bytes
Byte1: Header Byte 0xFE
Byte2: Header Byte 0xFF
Byte3: Header Byte 0x03
The value of “Volt” must be divided by ten. This provides one
decimal place resolution.
Byte4: Volt Hi Byte
Byte5: Volt Low Byte
CH1 Absolute Watt-Second counter.
This 5-byte counter increments with energy flowing in either direction (consuming or producing).
Byte6: CH1 W-S Byte1 (LSB)
Byte7: CH1 W-S Byte2
Byte8: CH1 W-S Byte3
Byte9: CH1 W-S Byte4
Byte10: CH1 W-S Byte5 (MSB)
I tried the following code to get the VOLTS, but its not working.
private void ProcessData(SocketPacket packet)
{
byte[] buffer = new byte[packet.ms.Length];
//packet.ms.Position = 0;
packet.ms.Seek(3, SeekOrigin.Begin);
packet.ms.Read(buffer,0,2);
int data = BitConverter.ToInt32(buffer, 0);
}
Can anyone offer some ideas?
Drew
|
|
|
|
|
without actaully testing anything, I believe this should work:
int voltsAsInt = (packet.ms[4] << 8) | (packet.ms[5]);
double actualVolts = voltsAsInt / 10;
|
|
|
|
|
hi I am creating an C# Application in which i am accepting values from the user for ex an ID. Depending on that id value i want to generate reports. the problem is that the ID is in many tables and i want data from all that table. can anybody help me out of this.
Thanks in advance.
|
|
|
|
|
Hi...
Could anyone show me the C# code to Drag and Drop from a Treeview to a Listview?
Thank You in advance...
|
|
|
|
|
First set AllowDrop = true
For treeview, handle ItemDrag event.
For listview, handle DragOver , DragEnter and DragDrop events.
For more details, have a look here[^]
Calin
|
|
|
|
|
Hi,
I want to source for .net obfuscators. Any recommendations ?
Thanks
|
|
|
|
|
Your post is gray because that question rolls in every two or three weeks. Here are some of the standard replies;
DotFuscator[^] - if you got Visual Studio, then you'll also have the community edition of this obfuscator. It's located in the "Visual Studio Tools"-folder in the start-menu.
Those are in competition with the Aspose[^] obfuscator. SkaterLight[^] is a less-known alternative, just like Eazfuscator[^].
Want to write your own? There's an article[^] on CP that explains how to obfuscate PHP code. There's also an open source project on CodePlex[^] to obfuscate .NET code.
There's a discussion on the usefullness here[^], and a very good alternative to obfuscating a lot can be found in the last paragraph of this[^] post.
Enjoy
I are troll
|
|
|
|
|
I am using html help workshop to create the .chm for one c# application.
I try to set the default page by change "project options" and set "default file", but it does not work.
when I open the .chm and it always display "This program cannot display the webpage" on the first page. it does not display the default page I set. I don't know the reason.
by the way, except this problem, .chm works fine.
anyone has used html help workshop and please give me one hint for it.
thanks.
|
|
|
|
|
Hi all.
As far as I know with Environment.CurrentDirectory we can get the current working directory.
But I'm gonna get the directory of my exe file (of my application), because sometimes the current directory is different with path of my application.
Could you guide me ?
Thanks in advance.
|
|
|
|
|
use Application.StartupPath .
Calin
|
|
|
|
|
Wow, very quick.
Thanks a lot Calin Tatar
|
|
|
|
|
I have buy'ed a set of buzz! wireless buzzer, which should work with pc also, and windows regonize them as a twenty button joystick, but no button press is regonized, as far i have read it should first recieve a message on the controlchannel, before working. Heres my problem i can't se the find any information about how to send a control signal to joystick.
Thomaxz
|
|
|
|
|
I don't know how much help it will be, but Pedram Amini wrote an in-depth article on reverse engineering a USB device's proprietary protocol at Python Interfacing a USB Missile Launcher[^]. Perhaps his (hers?) process will help you reverse engineer the Buzz! Wireless Buzzer.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Althroug theres i no software for pc, i can anaylse, i find a solution, in the article you link thers is a link to http://www.pcausa.com/Utilities/UsbSnoop/default.htm which i used to get vendor and procut id, with that i used the http://www.codeproject.com/KB/cs/USB_HID.aspx to send a recivedata and foudn it work almost as described http://www.vsj.co.uk/articles/display.asp?id=600 but it has an power safe function, which menas one of the lamp should be set on, before it will send any data.
Thank you very much for the Help
Thomaxz
|
|
|
|
|
Hello sir.
I have Big Problem in Middle Tire . what is this and why we used in .NET.
what is the baniftes of it. if u have ay example related to Midle Tire . then plz send me . my Email id is (khan.naim786@yahoo.com).
|
|
|
|
|
naim khan wrote: I have Big Problem in Middle Tire
I've always thought that Reliant Robins[^] are very strange cars and often they have a problem with their middle tire - well, the whole of the middle wheel.
Seriously now, as far as I can see you do not have a problem with your middle tier because it would appear that you don't have one. You have a problem with not having one.
naim khan wrote: what is this and why we used in .NET.
It is not just .NET it is any software development. You might want to read multi-tier architecture[^]
naim khan wrote: my Email id is
Keep it on the forum. If you keep it on the forum other people benefit.
|
|
|
|
|
Colin Angus Mackay wrote: very strange cars
Well, one got Del Boy and Rodney through all the series.
Ko seje so, nicu mu skakavci.
|
|
|
|
|
I would recommend running your posts through a spell checker, although it wouldn't have fixed 'tire', it would have fixed 'baniftes', and other stuff that makes this hard to read.
Beyond that, it's plain you have absolutely no idea what you're doing. So, buy some books and read them.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hello,
I'm interested in being able to pull the value of a cell in a selected row as the Type that the value was originally added to the DataGrid.
The data values are hWnds of all current process threads, which is of type System.IntPtr for the purpose of ShowWindow().
However, when I attempt to use the .Value with ShowWindow() as follows:
ShowWindow(dataGrid["hWndValue", dataGrid.CurrentRow.Index].Value, 1);
the call fails citing: cannot convert object to System.IntPtr.
I'm wondering if there is:
1) a way to convert the .ToString() value of dataGrid["hWndValue", dataGrid.CurrentRow.Index].Value to System.IntPtr?
2) a way to maintain the type of the data that was placed into the cell in the DataGrid?
Obviously, I'd rather not "be sloppy" and convert from a string to a IntPtr, but it'll work.
Any input is appreciated.
Thanks very much,
Matt Brown
[edit]
Although the above may be useful for me or others in the future; I was able to read the values into both a dictionary and the datagrid row, maintaining the type and allowing a lookup.
Dictionary<string,> ThreadHandles = new Dictionary<string,>();
try
{
ThreadHandles.Add(sb.ToString(), hWnd);
dataGrid.Rows.Add(sb.ToString(), hWnd);
}
catch
{
dataGrid.Rows.Add(sb.ToString(), hWnd);
}
[SOLUTION]
Thanks howlettt for the solution!
ShowWindow((System.IntPtr)(dataGrid["hWndValue", dataGrid.CurrentRow.Index].Value), 1);
modified on Friday, February 27, 2009 3:08 PM
|
|
|
|
|
ShowWindow(dataGrid["hWndValue", (System.IntPtr)dataGrid.CurrentRow.Index].Value, 1);
Should work
|
|
|
|